How to Export Text file from Business Central? - CloudFronts

How to Export Text file from Business Central?

Introduction:

Business Central provides you the feature to export the data in Excel in General Ledger entries, Customer Ledger entries, etc. But we can export data in a text file. In this blog, we will see how we can export data in the form of a text file.

Steps to achieve the goal:

  1. Create a codeunit that will export the data in text.
  2. We will be needing Temp Blob Codeunit, Instream, and OutStream to read and write the data in the file.
  3. Below is the code which will read and write the data in the text file.
  1. You can use dynamic filename also by assigning a field value in the FileName variable;
  2. FileName: Rec_ComapanyInformation.FileNameText // FileNameText is the field present in the Company Information Page which will be used as Filename of the exported text file.
  3. We will be also using an action that will call the Codeunit function (GenerateTextFile)
  1. The output of the above code is
  1. To avoid using multiple times Write Text function if there is a lot of data that needs to be pulled from multiple fields. You can use a variable and store all the values in that variable and then assign that variable in the WriteText function.

9. The output of the above code is

Conclusion:

   Thus we saw how we can export data from Business Central in a text file.

   Thank you very much for reading my work. Hope you enjoyed the article!


Share Story :

SEARCH BLOGS :

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange