This configuration points to the W1 Business Central OnPrem Docker Image. Now, let’s point to the Spanish one.
And let’s build a container.
Switching the Terminal part to AdvaniaGIT, I see that I am now pulling the Spanish Docker image down to my laptop.
This may take a few minutes…
After the container is ready I start FinSql.exe
Just opening the first table and properties for the first field I can verify than I have the Spanish captions installed.
So, let’s export these Spanish captions by selecting all objects except the new trigger codeunits (Business Central only) and selecting to export translation…
Save the export to a TXT file.
Opening this file in Visual Studio Code, we can see that the code page does not match the required UTF-8 format. Here we can also see that we have English in lines with A1033 and Spanish in lines with A1034.
We need to process this file with PowerShell. Executing that script can also take some time…
This script reads the file using the “Oem” code page. This code page is the one FinSql uses for import and export. We read through the file and every line that is identified as Spanish is the added to the output variable. We end by writing that output variable to the same file using the “utf8” code page.
Visual Studio Code should refresh the file automatically.
We need to create a “Translations” folder in the server folder. The default server uses the root Translations folder.
If you have instances then the “Translations” folder needs to be in the Instance.
Since I am running this in a container I may need to create this folder in the container.
Then, copy the updated file to the “Translations” folder.
And make sure it has been put into the correct path.
We need to restart the service instance.
Then in my Web Client I can verify that the Spanish application language is now available.
local procedure MyProcedure(varSalesHeader:Record"Sales Header")
Message('I am pleased that you called.');
What happens now is that Codeunit only has one instance for each session. When the first sales document is posted then the an instance of the Codeunit is created and kept in memory on the server as long as the session is alive.
This will save the resources needed to initialize an instance and tear it down again.
Making sure that our subscriber Codeunits are set to single instance is even more important for subscribers to system events that are frequently executed.
Note that a single instance Codeunit used for subscription should not have any global variables, since the global variables are also kept in memory though out the session lifetime.
Make sure that whatever is executed inside a single instance subscriber Codeunit is executed in a local procedure. The variables inside a local procedure are cleared between every execution, also in a single instance Codeunit.
The “Enabled” Codeunit will test for Setup table read permission and if the “Enabled” flag has been set in the default record.
LOCAL TestEnabled(VARTempBlob:Record TempBlob)
WITH JsonInterfaceMgt DOBEGIN
This is how we can make sure that a module is installed and enabled before we start using it or any of the dependent modules.
Table Access Interface
The main module has a standard response table. We map some of the communication responses to this table via Data Exchange Definition. From other modules we like to be able to read the response from the response table.
The response table uses a GUID value for a primary key and has an integer field for the “Data Exchange Entry No.”. From the sub module we ask if a response exists for the current “Data Exchange Entry No.” by calling the interface.
Some processes can be both automatically and manually executed. For manual execution we like to display a request page on a Report. On that request page we can ask for variables, settings and verify before executing the process.
For automatic processing we have default settings and logic to find the correct variables before starting the process. And since one module should be able to start a process in the other then we use the JSON interface pattern for the processing Codeunit.
We also like to include the “Method” variable to add flexibility to the interface. Even if there is only one method in the current implementation.
Reading through the code above we can see that we are also using the JSON interface to pass settings to the Data Exchange Framework. We put the JSON configuration into the “Table Filters” BLOB field in the Data Exchange where we can use it later in the data processing.
From the Report we start the process using the JSON interface.
This pattern is similar to the discovery pattern, where an Event is raised to register possible modules into a temporary table. Example of that is the “OnRegisterServiceConnection” event in Table 1400, Service Connection.
Since we can’t have Event Subscriber in one module listening to an Event Publisher in another, without having compile dependencies, we have come up with a different solution.
We register functionality from the functionality module and the list of modules in stored in a database table. The table uses a GUID and the Language ID for a primary key, and then the view is filtered by the Language ID to only show one entry for each module.
This pattern gives me a list of possible modules for that given functionality. I can open the Setup Page for that module and I can execute the Interface Codeunit for that module as well. Both the Setup Page ID and the Interface Codeunit ID are object names.
The registration interface uses the Method variable to select the functionality. It can either register a new module or it can execute the method in the modules.
WITH JsonInterfaceMgt DOBEGIN
LOCAL RegisterCollectionApp(JsonInterfaceMgt:Codeunit"IS Json Interface Mgt.")
Where the Subscriber that needs to respond to this Publisher is in another module we need to extend the functionality using JSON interfaces.
First, we create a Codeunit within the Publisher module with Subscribers. The parameters in the Subscribers are converted to JSON and passed to the possible subscriber modules using the “ExecuteMethodInApps” function above.
Having standard ways of talking between modules and solutions has opened up for a lot of flexibility. We like to keep our solutions as small as possible.
We could mix “Methods” and “Versions” if we at later time need to be able to extend some of the interfaces. We need to honor the contract we have made for the interfaces. We must not make breaking changes to the interfaces, but we sure can extend them without any problems.
By attaching the JSON Interface Codeunit to the post I hope that you will use this pattern in your solutions. Use the Code freely. It is supplies as-is and without any responsibility, obligations or requirements.
When the Business Central environment is built use the “Advania: Build C/AL Symbol References for AL” to enable the Side-by-Side development for this environment. This function will reconfigure the service and execute the Generate Symbol References command for the environment. From here on everything you change in C/AL on this environment will update the AL Symbol References.
So let’s try this out.
I converted my C/AL project to AL project with the steps described in my previous post. Then selected to open Visual Studio Code in AL folder.
In my new Visual Studio Code window I selected to build an environment – the Docker Container.
When AdvaniaGIT builds a container it will install the AL Extension for Visual Studio Code from that Container. We need to read the output of the environment build. In this example I am asked to restart Visual Studio Code before reinstalling AL Language. Note that if you are not asked to restart Visual Studio Code you don’t need to do that.
After restart I can see that the AL Language extension for Visual Studio Code is missing.
To fix this I execute the “Advania: Build NAV Environment” command again. This time, since the Container is already running only the NAV license and the AL Extension will be updated.
Restart Visual Studio Code again and we are ready to go.
If we build new environment for our AL project we must update the environment settings in .vscode\launch.json. This we can do with a built in AdvaniaGIT command.
We can verify the environment by executing “Advania: Check NAV Environment”. Everything should be up and running at this time.
Since we will be using Side-by-Side development for C/AL and AL in this environment we need to enable that by executing “Advania: Build C/AL Symbol References for AL”.
This will take a few minutes to execute.
Don’t worry about the warning. AdvaniaGIT takes care of restarting the service. Let’s download AL Symbols and see what happens.
We can see that AL now recognizes the standard symbols but my custom one; “IS Soap Proxy Client Mgt.” is not recognized. I will tell you more about this Codeunit in my next blog post.
I start FinSql to import the Codeunit “IS Soap Proxy Client Mgt.”
Import the FOB file
Close FinSql and execute the “AL: Download Symbols” again. We can now see that AL recognizes my C/AL Codeunit.
Now the upcoming release of Microsoft Dynamics 365 Business Central I need to supply more languages. What does a man do when he does not speak the language?
I gave a shout out yesterday on Twitter asking for help with translation. Tobias Fenster reminded me that we have a service to help us with that. I had already tried to work with this service and now it was time to test the service on my G/L Source Names extension.
In my previous posts I had created the Xliff translation files from my old ML properties. I manually translated to my native language; is-IS.
I already got a Danish translation file sent from a colleague.
Before we start; I needed to do a minor update to the AdvaniaGIT tools. Make sure you run “Advania: Go!” to update the PowerShell Script Package. Then restart Visual Studio Code.
Now, let’s prepare the Xliff files in Visual Studio Code. From the last build I have the default GL Source Names.g.xlf file. I executed the action to create Xliff files.
This action will prompt for a selection of language. The selection is from the languages included in the NAV DVD.
After selection the system will prompt for a translation file that is exported from FinSql. This I already showed in a YouTube Video. If you don’t have a file from FinSql you can just cancel this part. If you already have an Xliff file for that language then it will be imported into memory as translation data and then removed.
This method is therefore useful if you want to reuse the Xliff file data after an extension update. All new files will be based on the g.xlf file.
I basically did this action for all 25 languages. I already had the is-IS and da-DK files, so they where updated. Since the source language is en-US all my en-XX files where automatically translated. All the other languages have translation state set to “needs-translation”.
</trans-unit><trans-unit id="Table 102911037 - Field 1343707150 - Property 2879900210"size-unit="char"translate="yes"xml:space="preserve">
<note from="Xliff Generator"annotates="general"priority="3">Table:O4N GL SN - Field:Source Name</note>
All these files I need to upload to the Translation Service. From the Lifecycle Services menu select the Translation Service. This will open the Translation Service Dashboard.
Press + to add a translation request.
I now need to zip and upload the nl-NL file from my Translations folder.
After upload I Submit the translation request
The request will appear on the dashboard with the status; Processing. Now I need to wait for the status to change to Completed. Or, create requests for all the other languages and upload files to summit.
When translation has completed I can download the result.
And I have a translation in state “needs-review-translation”.
<trans-unit id="Table 102911037 - Field 1343707150 - Property 2879900210"translate="yes"xml:space="preserve">
A Codeunit that you can execute with CODEUNIT.RUN to perform a given task is, from my point of view, an interface Codeunit.
An interface Codeunit has a parameter that we put in the
This parameter is always a table object.
We have multiple examples of this already in the application. Codeunits 12 and 80 are some. There the parameter is a mixed set of data and settings. Some of the table fields are business data being pushed into the business logic. Other fields are settings used to control the business logic.
Table 36, Sales Header, is used as the parameter for Codeunit 80. Fields like No., Bill-to Customer No., Posting Date and so on are business data. Fields like Ship, Invoice, Print Posted Documents are settings used to control the business logic but have no meaning as business data.
Every table is then a potential parameter for an interface Codeunit. Our extension can easily create a table that we use as a parameter table. Record does not need to be inserted into the table to be passed to the Codeunit.
Let’s look at another scenario. We know that there is an Interface Codeunit with the name “My Interface Codeunit” but it is belongs to an Extensions that may and may not be installed in the database.
Here we use the virtual table “CodeUnit Metadata” to look for the Interface Codeunit before execution.
This is all simple and strait forward. Things that we have been doing for a number of years.
Using TempBlob table as a parameter also gives us flexibility to define more complex interface for the Codeunit. Tempblob table can store complex data in Json or Xml format and pass that to the Codeunit.
Let’s take an example. We have an extension that extends the discount calculation for Customers and Items. We would like to ask this extensions for the discount a given customer will have for a given Item. Questions like that we can represent in a Json file.
And the question can be coded like this.
The Interface Codeunit could be something like
With a Page that contains a single Text variable (Json) we can turn this into a web service.
Now I call out to all who are ready to help me with the translation. Please fork my NAV2018 repository and send me Xlf translation files for your native language. Or just download one of the translation files and send me your language.
Our next step is to code sign the App file and send it to Microsoft.
SETRANGE("Page ID",PAGE::"O4N GL SN Setup Wizard");
local procedure AddUserAccess(AssignToUser:Guid;PermissionSet:Code);
AppMgt:Codeunit"O4N GL SN App Mgt.";
with AccessControl dobegin
"User Security ID":=AssignToUser;
In the code you can see that this Codeunit is of Subtype=Install. This code will be executed when installing this extension in a database.
To confirm this I can see that I have the G/L Source Names Permission Sets in the Access Control table .
And my G/L Source Name table also has all required entries.
Uninstalling the extension will not remove this data. Therefore you need to make sure that the install code is structured in a way that it will work even when reinstalling. Look at the examples from Microsoft to get a better understanding.
Back to my C/AL extension. When uninstalling that one the data is moved to archive tables.
Archive tables are handled with the NAVAPP.* commands. The OnNavAppUpgradePerCompany command here on top handled these archive tables when reinstalling or upgrading.
Basically, since I am keeping the same table structure I can use the same set of commands for my upgrade Codeunit.
codeunit70009208"O4N GL SN Upgrade"
GLSourceNameMgt:Codeunit"O4N GL SN Mgt";
NAVAPP.RESTOREARCHIVEDATA(DATABASE::"O4N GL SN Setup");
NAVAPP.RESTOREARCHIVEDATA(DATABASE::"O4N GL SN User Setup");
NAVAPP.DELETEARCHIVEDATA(DATABASE::"O4N GL SN");
NAVAPP.DELETEARCHIVEDATA(DATABASE::"O4N GL SN Help Resource");
NAVAPP.DELETEARCHIVEDATA(DATABASE::"O4N GL SN User Access");
NAVAPP.DELETEARCHIVEDATA(DATABASE::"O4N GL SN Group Access");
So, time to test how and if this works.
I have my AL folder open in Visual Studio Code and I use the AdvaniaGIT command Build NAV Environment to get the new Docker container up and running.
Then I use Update launch.json with current branch information to update my launch.json server settings.
I like to use the NAV Container Helper from Microsoft to manually work with the container. I use a command from the AdvaniaGIT module to import the NAV Container Module.
The module uses the container name for most of the functions. The container name can be found by listing the running Docker containers or by asking for the name that match the server used in launch.json.
I need my C/AL extension inside the container so I executed
Now I am faced with the fact that I have opened PowerShell inside the container in my AdvaniaGIT terminal. That means that my AdvaniaGIT commands will execute inside the container, but not on the host.
The simplest way to solve this is to open another instance of Visual Studio Code. From there I can start the Web Client and complete the install and configuration of my C/AL extension.
I complete the Assisted Setup and do a round trip to G/L Entries to make sure that I have enough data in my tables to verify that the data upgrade is working.
I can verify this by looking into the SQL tables for my extension. I use PowerShell to uninstall and unpublish my C/AL extension.
I can verify that in my SQL database I now have four AppData archive tables.
Pressing F5 in Visual Studio Code will now publish and install the AL extension, even if I have the terminal open inside the container.
The extension is published but can’t be installed because I had previously installed an older version of my extension. Back in my container PowerShell I will follow the steps as described by Microsoft.
So, where is step 1? Step 1 was converting C/AL code to AL code. This we did with AdvaniaGIT and was demonstrated here.
First thing first! I received the following email from Microsoft.
The decision has been made by our SLT, that the use of a Prefix or Suffix is now a mandatory requirement. If you are already using this in your app(s), great. If not, you will want to do so.
We are coming across too many collisions between apps in our internal tests during builds and have seen some in live tenants as well. It makes the most sense to make this a requirement now. If you think about it in a live situation, if a customer installs an app before yours and then tries yours but gets collision issues, they may just decide to not even continue on with yours.
Also, I have been made aware that adding a prefix or suffix after you already have a v2 app published can make the process complicated for you. Therefore, since you all have to convert to v2 anyway, now is a good time to add in the prefix/suffix.
The following link provides the guidelines around using it here
If you haven’t reserved your prefix yet, please email me back to reserve one (or more if needed).
Since my brand is Objects4NAV.com I asked for 04N as my prefix and got it registered. Since we got this information from Microsoft, every object that we develop in NAV 2018 now has our companies prefix in the name.
Starting my AL development by opening Visual Studio Code in my repository folder. I updated my setup.json to match the latest preview build as Docker container and then selected to Build NAV Environment using AdvaniaGIT.
After download and deployment of the container I noticed that the container had a brand new version of the AL Extension for Visual Studio Code. I looked at the version installed and that was an older version.
I uninstalled the AL Language extension and restarted Visual Studio Code.
As you can see on the screenshot above we now don’t have any AL Language extension installed. I executed the Build NAV Environment command from AdvanaiGIT to install the extension on the Docker container. In this case I already had a container assigned to my branch so only three things happened.
uidOffset in the container database was updated. This is recommended for C/AL development.
License file is updated in the container database and container service. The license used is the one configured in branch setup.json or the machine settings GITSettings.json
AL Language Extension is copied from the container to the host and installed in Visual Studio Code.
Again, restarting Visual Studio Code to find that the latest version of AL Language Extension has been installed.
I then executed two AdvaniaGIT actions.
Update Launch.json with current branch environment. This will update the host name and the service name in my AL Launch.json file to make sure that my AL project will be interacting with the branch container.
Open Visual Studio Code in AL folder. This will open another instance of Visual Studio Code in the AL folder.
Immediately after Visual Studio Code was opened it asked for symbols and I agreed that we should download them from the container.
Everything is now ready for AL development using the latest build that Microsoft has to offer.
I started Edit – Replace in Files in Visual Studio Code. All my objects have a name that start with G/L Source Name. I used this knowledge to apply the prefix.
By starting with the double quote I make sure to only update the object names and not captions. All captions start with a single quote. I got a list of all changes and needed to confirm all changes.
The field name I add to G/L Entry table does not match this rule so I needed to rename that my self. Selecting the field name and pressing F2 allows me to rename a field and have Visual Studio Code update all references automatically.
Pressing F5 started my build, publish and debug.
My extension is installed and ready for testing.
There are a few more steps that I need to look into before publishing the new version of G/L Source Names to Dynamics 365. These steps will appear here in the coming days. Hope this will be useful to you all.