How to Upload and Read a Text File in Dynamics 365 Business Central 27 Using AL Code.
Introduction
Imagine you’re working at a retail company that frequently updates discount codes for promotions. The marketing team maintains a simple .txt file containing all active discount codes and hands it over to the IT department to upload into Business Central.
In a retail business, discount codes change often. Typically, the marketing team compiles them into a simple .txt file and passes it to IT for upload into Microsoft Dynamics 365 Business Central(Business Central).
Before Business Central 27, importing such static files required external storage or complicated integrations. With the new NavApp.GetResourceAsText() method, you can now embed and read .txt files in your AL(Application language) extension.
Advantages of using ‘NavApp.GetResourceAsText()’
Files (like .txt, .json) are packaged inside the .app
Since resources are embedded, users don’t need separate permissions to access file systems.
No manual copying of files across environments.
Files are read directly from the extension package.
Works not only with .txt, but also.json, .xml, or other structured text resources.
In this tutorial, we’ll walk through how to upload and read a text file in Microsoft Dynamics 365 Business Central 27 using AL Code and the NavApp.GetResourceAsText().
Declare the Resource in app.json
First create an AL Project, inside the folder create a folder (i,e Resources) to keep the text file as shown in below pic.
Make sure app.json includes the correct runtime and resource declaration:
In the app.json file add the resource folder.
Create the Page with Action
Create a simple card page with an action button to read the file:
Code:
Publish the extension to business central (BC). After publishing the code
Go to your custom page and click on your Action button
On clicking the action button we will get the response as:
Conclusion
The NavApp.GetResourceAsText() method in Business Central 27 makes it easier than ever to manage embedded resources within AL extensions. By packaging files directly inside the .app, we eliminate external dependencies, simplify deployment, and improve both security and maintainability.
For more details like this please follow our company LinkedIn page where you will get all the new updates every week: