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.

Saurav Dhyani


Popular posts from this blog

Welcome - Microsoft Dynamics 365!

Hi All, In this article we will discuss the new introduced member of Dynamics Family. Yes you heard it correctly, one more new member with Name "Microsoft Dynamics 365" . #ProjectMadeira   #Dynamics365

Send Mail with Attachment From Navision.

Hi all, We have seen how to save a report into PDF and how to send mail to a customer. Let's link these two post in one i.e. Mailing statement to a customer into PDF Format. This article is part of the Series. Please Refer  Table of Content here . If you have the old objects set let me brief you what I will be changing - 

NAV 2013 Credential Type - How to Use?

Hi all, Please do these activities when you have time, its a long activity and i would suggest do all activities in one go. So be clam and lets start. For NAV 2013 R2 Refer Here. For NAV 2016 Steps have been Reduced Please Refer Here. I have installed NAV 2013 and its work great with my windows credentials. I was checking the service console (Microsoft Dynamics NAV Administration) in NAV 2013 and found out that Credentials Type have multiple Options.