The new AL Language version 14.2 introduces the possibility to package resources inside an AL extension and use those resources from your AL code. This feature is a great addition because it permits you to add images, data file, configuration packages and more into your AL extension’s package and then use them at runtime (during the installation phase or in your standard code).
How to add resources to AL extensions
To add resources in an AL extension, you need to create inside your AL project a folder (or a set of folders) where you will place your resources and then list those folders in the new resourceFolders property in the extension’s app.json file.
To give you an example, here is an extension where I have created a Resources folder with some subfolders on it. As you can see, I have a data subfolder containing a txt file and a json file and an images subfolder containing a PNG file.
In the app.json file, I simply set “resourceFolders”: [“Resources”] (top level folder containing my extension’s resource files):
If you have more than one top level folders for resources, simply list them in the resourceFolders array.
How to access resources from AL code
To access those resources from AL code, you can use the new NavApp.GetResource method and its derivates:
procedure GetResource(ResourceName: Text, var ResourceStream: InStream, [Encoding: TextEncoding]) : Retrieves a resource that was packaged with this app and loads it into the specified InStream
procedure GetResourceAsText(ResourceName: Text, [Encoding: TextEncoding]): Text : Retrieves the specified resource as Text
procedure GetResourceAsJson(ResourceName: Text, [Encoding: TextEncoding]): JsonObject : Retrieves the specified resource as a JsonObject
Here a snippet of code that shows how to load the data of the resources I’ve packaged with my extension from AL code:
As you can see, it’s very easy…
Please remember that resources can only be accessed within the scope of the app that contains them. This means that there is no way to access the resources of another app.
Names for resources (data file) must be unique for folders, otherwise you will have an error.
Obviously, there are limits on the size of the resources and the extension’s file containing them (entire package):
- Max 1024 Kb per resource
- Max 16 MB for the entire extension’s package
- Max 265 resources per package
All resources that you will package inside an extension are virus scanned at server side (security first 😉).



Ciao,
non funziona in nessun caso almeno in cloud.
Ho provato in tutti i modi ma quando effettua il deploy dell’app non si porta dietro la cartella con le risorse quindi non trova mai nessuna risorsa.
inoltre le funzioni che utilizzi :
NavApp.GetResourceAsText
NavApp.GetResourcesAsJson
sono per il runtime 14.2 mentre in cloud siamo solo alla 14.1 in questo momento
NavApp.GetResources è l’unica funzione permessa
Probabilmente i test li hai fatti on Premise
LikeLike
E’ richiesta versione 25.2 o superiori.
LikeLike