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:
- Create a codeunit that will export the data in text.
- We will be needing Temp Blob Codeunit, Instream, and OutStream to read and write the data in the file.
- Below is the code which will read and write the data in the text file.
- You can use dynamic filename also by assigning a field value in the FileName variable;
- 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.
- We will be also using an action that will call the Codeunit function (GenerateTextFile)
- The output of the above code is
- 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!
Related posts:
How to review and accept changes to confirmed Purchase Orders in D365 F&O
How to run an SSRS report on a selected record in the CRM using FetchXml
Project Operations as source of truth for Professional Services Organizations
Streamlining Build Pipelines with YAML Template Extension: A Practical Guide