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

BC 21 and Higher - PowerShell Cmdlet (Replacement of Business Central Administration).

Hi Readers, As discussed in last article about deprecating of Business Central Administration, there are few common actions that we use in administration till Business Central 20. For our on-prem customers, we will still require doing activities. As Microsoft suggest we need to start using PowerShell cmdlet.    Let's see how to do those via PowerShell, or Administration Shell. I will be keep adding commands as you comment to this article.

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 - 

MSDYN365BC - Data Upgrade To Microsoft Dynamics 365 Business Central on premises.

Hi Readers, We have already talked about the number of steps for upgrading to Business Central on Premises from different NAV versions. After that article, I received multiple requests for an article which list down steps for Data Migration. In this article, we will discuss steps of data migration to MSDYN365BC (on-Prem) from NAV 2017. For this article, I am considering a Cronus Demo Database without any customization. For an actual upgrade project, we will have to complete object merge using compare and Merge process. After the Merge Process, the next step is data migration. Let's discuss those steps. Direct Upgrade to Microsoft Dynamics 365 Business Central (on-Prem) is from following versions - 1. NAV 2015. 2. NAV 2016. 3. NAV 2017. 4. NAV 2018.