Developing Extensions in AL Using Visual Studio Code - Part 2
In the Part 1 of this tutorial, we learned how to create table and page.
In this second part, we will extend a standard object by adding field to a table and page and we will learn how to translate your AL project into a variety of languages.
So, let’s open our ClaimManagementExt application into Visual Studio Code.
Implement No. Serie Design Pattern
- Extend standard object
Create new file and call it "MarketingSetupExt.al"
Note: We will use only one file to extend both table and page but it’s not mandatory.
Use shortcut ttableext to create the basic layout for a table extension and tpageext to create the basic layout for a page extension.
- Add new field
The keyword addafter() allow us to place fields and groups on the page.
- Open Claim.al and add new field and add a new field "No. Serie"
- Modify the field No. like below
- Add OnInsert trigger
- Publish and Test Application
As you can see, the field is added in the page after the “Opportunity Nos.”
Navigate to Claim list and create a new claim
Translate application
Now, we need to manage languages for our application.
To do this we need to update our app.json by adding this setup then publish.
"features": [
"TranslationFile"
]
A new directory Translations which contain a new file ClaimManagementExt.g.xlf are generated.
Note: The auto generated file is not a properly formatted translation file.
Normally in a properly formatted file, we had both the ‘Source’ and the ‘Target’ properties.
As we can see is the .g.xlf file generated, there is only a ‘Source’ property even though the ‘Target-language’ of the file is set to ‘en-US’.
Thanks to Tobias Fenster who has developed a good VSCode extensions ALRunner, we can convert the translation file into a properly formatted file.
After installing the ALRunner extension, press Ctrl+p and choose ALRunner: Convert generated. xlf to real one
Save the generated file under Translations Directory
Note: The .g.xlf file gets overwritten each time we build our AL project, so use it as source for generating other translation file.
For our purpose, we generate two files:
- ClaimManagementExt_EU.xlf (Contain the English caption)
- ClaimManagementExt_FR.xlf (Contain Frensh caption)
For the ClaimManagementExt_EU.xlf we set the value of ‘Target-language’ to ‘en-US’ and ‘fr-FR’ for in ClaimManagementExt_FR.xlf
For both files, keep value of the ‘Source’ Property and modify the ‘Target’ value’s if needeed.
For our purpose, we will just modify the ClaimManagementExt_FR.xlf
When done, just publish your application and ENJOY.
In the next part of this guide, we will be seeing the procedure to create a custom workflow based on events.
Stay tuned.
Please state the page feature you applied on the field 'Description reclamation', thanks
As-Salaam-Alaikum Mehdi, can you please provide the full code? cause it looks these variables are missing where to add this variables? My email id: tabrezajaz@hotmail.com