Package resources in extensions and access from AL
Enabled for | Public preview | General availability |
---|---|---|
Admins, makers, marketers, or analysts, automatically | ![]() |
![]() |
Business value
Features often require some data—for example, to initialize and set up. Until now, it has only been possible to add such data and consume from AL through the use of labels or code. In this release, we're adding the ability to include resources in extensions and access these from AL.
Feature details
Developers will be able to package resources in extensions and access the content of these resources from within AL code. This can be used to ship data for setup and initialization features (for example, for RapidStart packages, demo data, templates, and more), thereby avoiding having to use labels or codeunits for this purpose.
To package resources in an extension, you need to declare which folders within your project contain resources to be packaged in the extension's manifest file (app.json). To do this, add the "resourceFolders" property to the manifest file. You can specify multiple folders; resource folders can contain subfolders as well.
Resources can be accessed from AL code at runtime. Several methods can be used to interact with resources:
- NavApp.GetResource(ResourceName: Text; var ResourceStream: Instream; (Optional) Encoding: TextEncoding) is used to read the content of resource files at runtime.
- NavApp.GetResourceAsText(ResourceName: Text; (Optional) Encoding: TextEncoding): Text is used to read the content of resource files directly into a Text object.
- NavApp.GetResourceAsJson(ResourceName: Text; (Optional) Encoding: TextEncoding): JsonObject is used to read the content of resource files directly into a JsonObject.
Note that an extension is only able to access its own resources.
These are the current size limitations on resources:
- Maximum size of any single resource file is 16 MB.
- Maximum size of the total of all resource files is 256 MB.
- Maximum number of resource files in an extension is 256 files.
Tell us what you think
Help us improve Dynamics 365 Business Central by discussing ideas, providing suggestions, and giving feedback. Use the forum at https://aka.ms/bcideas.
Additional resources
Adding and accessing resources in Business Central extensions (docs)