OneByte: Converting C/AL Code to AL in Microsoft Dynamics 365 Business Central | OnActuate
 In A-ERP, A-How To

Microsoft Dynamics 365 Business Central (D365 BC) continues to evolve, bringing new features and capabilities to streamline business processes. In D365 BC, one of the key advancements is the ability to convert C/AL (C/SIDE) code to the new AL format, making it compatible with modern extensions for D365 BC. This conversion process is facilitated by the Txt2AlConverter tool, simplifying the transition from legacy code to the latest development standards.

Understanding Txt2AlConverter

The Txt2Al conversion tool is a powerful utility that allows you to take existing C/AL objects, originally created in Dynamics NAV or Business Central Spring 2019 (version 14), and seamlessly transform them into the modern .al format. The .al format is essential when developing extensions for D365 BC.

The conversion process involves two key steps:

  • Run the Dynamic Nav Development Shell as Administrator.
  • Export the objects using the following syntax:

ExportToNewSyntax, File=<filename.txt>, Database=”<databasename>”, ServerName=<servername>,

Filter=Type=table;ID=<tableID>

Exporting Objects from C/SIDE in a Cleaned .txt Format

To begin, you need to export your existing C/AL objects from C/SIDE in a cleaned .txt format. Follow these steps:

  • Run the Dynamic Nav Development Shell as Administrator.
  • Export the objects using the following syntax:

ExportToNewSyntax, File=<filename.txt>, Database=”<databasename>”, ServerName=<servername>,

Filter=Type=table;ID=<tableID>

Example:

Export-NAVApplicationObject -DatabaseName “Demo Database BC (17-0)” -Path

E:\Setups\CAL\CAL.txt -DatabaseServer OAIDB\NAVDEMO -ExportToNewSyntax ExportTxtSkipUnlicensed -Filter Modified = True

Converting Objects from C/AL to AL

Once you have the cleaned .txt files, you can proceed with the conversion to AL format. Follow these steps:

  • Run CMD as an administrator.
  • Navigate to the path:

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

using the following command:

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

Convert the C/AL objects to AL using the following syntax:

 

 

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

Example:

Txt2al –source=”E:\Setups\CAL” –target=”E:\Setups\AL” –extensionStartId=50000

 

Parameters Explanation

Here are the parameters used in the conversion process:

  • source=Path: Specifies the directory containing the .delta files.
  • target=Path: Specifies the directory for the converted AL files.
  • rename: Renames the output files to prevent clashes with the source .txt files.
  • type=ObjectType: Defines the type of object to convert (e.g., Codeunit, Table, Page, Report, Query, XmlPort).
  • extensionStartId: Sets the starting numeric ID for extension objects.
  • injectDotNetAddIns: Injects the definition of standard .NET add-ins in the resulting .NET package.
  • dotNetAddInsPackage=Path: Specifies the path to an AL file containing a definition for a .NET package.
  • translationFormat=ObjectType: Specifies the format for generating translation files (Xliff, Lcg).
  • addLegacyTranslationInfo: Adds information to the translation file to facilitate migration of existing translations.

Conclusion

With Txt2AlConverter in D365 BC, the process of converting C/AL code to AL has never been easier. This transformation allows organizations to embrace the latest development standards and take full advantage of the modern extension capabilities offered by D365 BC. By following the steps outlined in this article, you can seamlessly transition your legacy code and unlock new possibilities for your ERP system.

 

About the expert

Samridhi Binjola, Business Central Technical Consultant, OnActuate

Samridhi Binjola is a seasoned Business Central Technical Consultant at OnActuate, with a rich background of over 4.5 years in Microsoft technologies. Her proficiency encompasses diverse development across various modules and versions of Dynamics NAV or Business Central, report generation, skilled customer support, and proficiently managing multiple projects. Additionally, she holds the esteemed MB-800 certification, solidifying her expertise in the field.

The “OneByte” blog series are technical how-to articles by OnActuate’s expert consultants covering Microsoft Business Applications (Microsoft Dynamics, Power Platform) and related technologies. Have a topic you’d like to learn more about? Email us at info@onactuate.com!

Our website uses cookies to personalize and enhance your experience and improve the delivery of information to you. By clicking "Accept", you agree to our use of cookies. Click “Learn more” to read our Privacy Policy