Skip to main content

The Txt2Al Conversion Tool: How to Export Dynamics NAV objects (.txt) and converting to AL

Hi folks,

In this article, I will show you how you can use Txt2Al conversion tool that is the part of NAV 2018 and Dynamics 365 Business Central On-Premise.

Using this Txt2Al conversion tool you can take existing Dynamics NAV objects that have been exported in .txt format and convert them into the new .al format and use these .al format file directly using Visual Studio Code to develop/build extensions for Dynamics 365 Business Central.

Converting the NAV objects consists of following 2 steps:

1. Exporting the objects from C/SIDE [Either from Development Environment or using PowerShell Command]
2. Converting the objects to the new syntax.

You can find Txt2Al tool in following location if you installed Dynamics 365 Business Central On-Premise on your machine:
C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\140\RoleTailored Client\Txt2Al.exe

Steps to use the Txt2Al conversion tool: Reference
Step 1: Compile your Dynamics NAV DB
Step 2: Export all baseline objects sue following steps: using following command line:
* Create 2 folders in any drive where you want to export NAV objects and want to put converted .al files

Example :- Drive = C  >> Folder = TXT2AL  >> Subfolder 1 = AL  and Subfolder 2 = Tab.

* Open Command Prompt as Administrator
* Navigate to C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\140\RoleTailored Client\
command line: cd C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\140\RoleTailored Client
* And execute following command line to export all table object:
finsql.exe Command=ExportToNewSyntax, File=C:\TXT2AL\Tab\AllExportedTableObjects.txt, Database="Demo Database NAV (14-0)", ServerName=.\SQLSERVER,Filter=Type=table;
 
*
 After Successful execution of above command you will get the .txt file that contains all table objects in it

To export specific table object use following command line:
finsql.exe Command=ExportToNewSyntax, File=<path\filename.txt>, Database="<databasename>", ServerName=<servername> ,Filter=Type=table;ID=<tableID>
e.g. finsql.exe Command=ExportToNewSyntax, File=C:\TXT2AL\Tab\exportedNewModifiedObjects.txt, Database="Demo Database NAV (14-0)", ServerName=.\SQLSERVER ,Filter=Type=table;ID=50001
Similarly, for
Tables: 
Type= table; ID='50000..50005';
Pages: 
Type= 'page'; ID='50000..50005';
Queries:
Type= 'query'; ID='50000..50005';
Reports:
Type= 'report'; ID='50000..50005';
Menusuite:
Type= 'menusuite'; ID='50000..50005';
XMLPort:
Type= 'xmlport'; ID='50000..50005';
NOTE: TXT2AL requires objects exported in New Syntax


To export all new and/or modified objects use following command line:
finsql.exe Command=ExportToNewSyntax, File=<filename.txt>, Database="<databasename>", ServerName=<servername> ,Filter=Type=table;Modified = Yes
e.g. finsql.exe Command=ExportToNewSyntax, File=C:\TXT2AL\Tab\AllExportedTableObjects.txt, Database="Demo Database NAV (14-0)", ServerName=.\SQLSERVER ,Filter=Type=table;Modified = Yes

Step 3: After getting .txt files in Tab folder, just run these 2 commands..

(1) cd C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\140\RoleTailored Client

(2) Now use Txt2Al tool to convert the exported object to AL:

Syntax: txt2al --source --target --rename --type --extensionStartId --injectDotNetAddIns --dotNetAddInsPackage --dotNetTypePrefix --translationFormat --addLegacyTranslationInfo

Example :-
txt2al --source=C:\TXT2AL\Tab\ --target=C:\TXT2AL\AL\ --rename --extensionStartID 50100


Output :-

Output - Command Prompt

Now if you go in AL folder you will get the converted AL file.


I hope this article will help you when you will try to convert Dynamics NAV C/AL object (.txt) source code to AL.

Keep in touch for more articles!!!!

Comments

Popular posts from this blog

Flow Custom field to G/L Entry and other Posted tables : From Purchase Order to Posted Purchase invoice

Hi Readers, In this blog we will see how we can transfer data from " Purchase Header" to "Purchase Invoice Header" & "G/L Entry" table in Business Central. In this example, will create "Remarks" field on Purchase Header table and after posting, flow it to Purchase Invoice Header & G/L Entry tables: Firsly, create required fields ("Remarks") in below mentioned tables by creating table extensions: Purchase Header (38) Purch. Inv. Header (122) Gen. Journal Line (81)  G/L Entry (17) For the Purch. Inv. Header table, you can just create copy the field from purchase header and paste it in  Purch. Inv. Header  table. If the field ID No. is same for that field for both the tables then you don't have to code i.e, it automatically transfer that field data from Purch. Header to Purch. Inv. Header . Step-(1)   tableextension   50104  "Purchase Header Ext"  extends  "Purchase Header" {      fields     {         

Amount In Words in Navision / Business Central

Hi Guys, In this article, we will see how to display amount in words in Microsoft Dynamics Business Central. Here, I am taking an example of Report object  which is widely used in Navision for converting decimal amount field into words. Procedure :-  Step-1 Declare the following Global Variables :         RepCheck:  Report  "Check";         NoText:  array [ 2 ]  of   Text ;         AmountInWords:  Text ; where, (1) RepCheck is a variable of  Report DataType Named as " Check " which is 1401. (2) NoText is a variable of DataType " Text " with array Dimension value as 2 which is defined as shown above. (3) AmountInWords is a variable of DataType " Text " which will store final result of amount in words. Step-2 Now, add the following code in OnAfterGetRecord() trigger of DataItem containing that decimal field value. So in my custom Purchase Order Report, i am adding code in the Purchase Header (DataItem) - OnAfterGetRecord() trigger.   trigger  OnA