Since the launch of Microsoft Dynamics 365 Business Central, a lot of customers are interested in to use 365 BC and along with it, they are also emphasizing to use existing on-premise customization/solutions (or equivalent) on 365 BC as well. Keeping in mind about the customer's demands ISVs and Microsoft Dynamics Partners are in the struggle of upgrading their on-premise solution(s) to cloud based solution in the form of apps/extensions.
At Dynamics 360, along with other services we also provide Microsoft Dynamics NAV & 365 Business Central solutions and to meet the customer demands, the first question always came in mind is, that how can we do this upgrade in the earliest possible time with quality and as per customer demand and need? Do we have any automated tool or defined process? So, the good news is YES, we do have a tool know as txt2al provided by Microsoft, which helps to generate AL code from the existing C/AL (new syntax, will talk about this as well in this post). Isn't amazing? Yes, it is as you don't have to write AL code from the scratch to develop extension(s).
The agenda of this post is to demonstrate that how you can export existing object from Dynamics NAV/365 Business Central on-premise database in new syntax as txt and then from that .txt(.delta) file, how we can generate AL code.
Demo:
For demo purpose I would be using following tools:
- Microsoft Dynamics 365 Business Central (on-premise)
- Command Prompt (cmd)
Setps:
- Run Command Prompt as Administrator
- Change directory to point RTC folder. If you are using Microsoft Dynamics 365 Business Central then your command would be like:
cd C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\130\RoleTailored Client
But if you are using dynamics NAV 2018 then your command would be like:
C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client - Now export the object in new syntax in .txt format using command as follow:
f you are using Microsoft Dynamics 365 Business Central then your command would be like:
finsql.exe Command=ExportToNewSyntax, File="E:\Demo\Modified\RP50000.txt", Database="Demo Database NAV (13-0)", ServerName=.\NAV13 ,Filter=Type=report;ID=50000
But if you are using dynamics NAV 2018 then your command would be like:
finsql.exe Command=ExportToNewSyntax, File="E:\Demo\Modified\RP50000.txt", Database="Demo Database NAV (11-0)", ServerName=.\NAV11 ,Filter=Type=report;ID=50000
In my case: I am exporting Report 50000 which I developed. You need to change the above mentioned command as per your need. You can get more details about finsql parameters from here.
After running the above statement if I go to the specified path in File parameter, E:\Demo\Modified\ I would be able to see a .txt file name as RP50000.txt
If you have multiple objects to export, I suggest to export each object as seperate txt file. I will help you to generate separate .al file for each object - After exporting object, run the following command to convert the C/AL in .txt file into AL.
txt2al --source="E:\Demo\Modified" --target="E:\Demo\AL" --extensionStartId=50000
You can know more about txt2al at: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-txt2al-tool - Now you can use the .al file generated at the path specified in target parameter which is in my case is: E:\Demo\AL
In my next post I would be showing you that how you can use this .al file in your al project and build extension 2.0 using Visual Studio Code.
You can know more about AL development at https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-dev-overview
*This post is locked for comments