Skip to main content

#msdyn365bc - Say Hello to Base64 Convert?

Hi Readers,

In last article we created tables and pages required to store attachment in #msdyn365bc or #msdynnav.

If you want to see other articles in this series please check here.

In this article we will understand How to use Base64 Conversion in #msdyn365bc and #msdynnav. 

To transfer files, we cannot do it as a file but Base 64 can help us to do the magic.

What is Base 64?

  • Base64 is the most popular binary-to-text algorithm used to convert data as plain text in order to prevent data corruption during transmission between different storage mediums. 
  • In addition, it is often used to embed binary data into text documents such as HTML, CSS, JavaScript, or XML.

Read More about Base 64 here.

For File Handing we will add functions to Export and Import attachment in Business Central.

For Importing Attachment there are two ways based on what approach you are using. 

Method 1 - Using TempBlob Table.

The Procedure accepts a Text parameter and we will use the build in function FromBase64String to convert the Text value to a Blob Field.

Later on we will transfer that blob to our Record.

The Text value that passed in the procedure is a Bit 64 value.

Method 2 - Using Temp Blob Codeunit.

As we all know Microsoft have planned to remove the Tempblob table from the Base application extension and will be replaced by Temp Blob Codeunit.

Additionally Microsoft have added a separate Codeunit for Base 64 Convert which have multiple overloads.

  • 4 Overloads for FromBase64.
  • 7 Overloads for ToBase64.

I am sure you will find the overload that you will like in your scenario. we will use one that fits to the scenario that we are working on.


For Exporting/Downloading Attachment from #msdyn365bc we will add a procedure.

This procedure will check if there a attachment and if yes then Put in stream and then download from Stream to the client.

To make these functions available for users we will add these in pages that we have created in Last article.

We have one more step before we start testing the sample that we are developing.

In next article we will add a new API Page.

Stay Tuned. Let me know your views as comment to this article.

Regards,
Saurav Dhyani
www.sauravdhyani.com

Comments

  1. Another extremely useful contribution. Thanks, Saurav!

    ReplyDelete
    Replies
    1. Thankyou Justin for the comment. Hope you are also noticing new content on YouTube channel. https://www.youtube.com/@SauravDhyani

      Delete

Post a Comment

Popular posts from this blog

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.

NAV 2013 Upgrade Part III - Data Upgrading.

Hi all, As per agenda we need to discuss the data upgrade in NAV 2013. The process is similar to what used to be till NAV 2009 R2 but with some changes. Let's start the process. Remember -  1) You can only upgrade a database to NAV 2013 from NAV 2009 SP1 / R2 SQL Only. 2) The Synchronization of users with SQL Server is no more required.