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 add an Entity and fields in Global Search On Dynamics 365 CRM
How to create a SharePoint site and enable Server-Based SharePoint Integration for Document Manageme...
Posting Restriction in Business Central for different users for Purchase and Sales documents
Quality Management Process in Dynamics 365 Supply Chain Management - Part 2