Dynamics 365 Business Central: Converting C/AL objects to .al format (Txt2Al Conversion Tool)

Dynamics 365 Business Central

Hi, Readers.
Last week, I was asked if there is any way to convert C/AL objects to .al format. Perhaps there have been more upgrade cases recently, this is a good thing. So today I’d like to talk briefly about this topic in this post.

Microsoft actually provides a tool for this in BC14, Txt2Al Conversion Tool.
The Txt2Al conversion tool allows you to take C/AL objects, which were created in Dynamics NAV or Business Central Spring 2019 (version 14), and convert them into the new .al format. The .al format is used when developing extensions for Dynamics 365 Business Central. Converting the objects consists of following two steps:

  1. Exporting the objects from C/SIDE in a cleaned .txt format.
  2. Converting the objects to the new syntax.

Note: You can only convert .txt format to .al format, not .fob. So you need Development license or Partner license of NAV to export C/AL objects to text first.

Where to get the Txt2Al conversion tool

The Txt2Al conversion tool (txt2al.exe) is only available with version 14, which is the last version to support C/AL. Use this version no matter what later version you may eventually be upgrading to. The AL objects created by the tool will be compatible with later versions.

You find the txt2al.exe on the installation media (DVD) in the “DVD\RoleTailoredClient\program files\Microsoft Dynamics NAV\140\RoleTailored Client” folder. Or, it’s installed locally with Dynamics NAV Development Environment, for example, in the “C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\140\RoleTailored Client” folder.

So when you use this tool, you don’t need to install BC14 on purpose, just download the installation media (DVD).

PS: You download the latest CU of BC14:
Released Cumulative Updates for Microsoft Dynamics 365 Business Central Spring 2019 Update on-premises

Note again: The Txt2Al conversion tool (txt2al.exe) is only available with version 14 (BC14)
For example, you can not find the txt2al.exe in BC18.x folder.

Using the Txt2Al conversion tool

I prepare two C/AL objects in C:\Temp\NAV Objects folder.

Then create a folder for the new AL Objects, for example, C:\Temp\NAV Objects\AL Obejcts.

Run Command Prompt as administrator.

Open the folder where txt2al.exe is.

cd C:\Temp\CU 26 Spring 19 Update W1\Dynamics.365.BC.47563.W1.DVD\RoleTailoredClient\program files\Microsoft Dynamics NAV\140\RoleTailored Client

Then run the convert command.
A most simple example:

txt2al --source "C:\Temp\NAV Objects" --target "C:\Temp\NAV Objects\AL Obejcts"


Test Video:

All Parameters:

–source=PathRequired. The path of the directory containing the .delta files.
–target=PathRequired. The path of the directory into which the converted AL files will be placed.
–renameRename the output files to prevent clashes with the source .txt files.
–type=ObjectTypeThe type of object to convert. Allowed values: Codeunit, Table, Page, Report, Query, XmlPort
–extensionStartIdThe starting numeric ID of the extension objects (Default: 70000000). It will be incremented by 1 for each extension object.
–stacktraceDisplay the stack trace of exceptions raised during the conversion.
–helpShow help screen.
–injectDotNetAddInsInject the definition of standard .NET add-ins in the resulting .NET package. The standard .NET add-ins are a set of add-ins that are embedded into the platform.
–dotNetAddInsPackage=PathSpecify the path to an AL file that contains a definition for a .NET package containing .NET type declarations that should be included in the .NET package definition that’s produced by the conversion. This parameter should be used to inject a custom set of .NET control add-in declarations. The file should contain something similar to the example shown below.
–multithreadedRun using multiple threads. This parameter improves performance but results in non-repeatable extension numbers and .xlf content.
–dotNetTypePrefixSpecify a prefix to be used for all .NET type aliases created during the conversion.
–translationFormat=ObjectTypeSpecify the format to use when generating translation files. The allowed values are: Xliff, Lcg.
–addLegacyTranslationInfoAdd information to the translation file that can be used to migrate existing translations/translated resources. During conversion, XLIFF files from all the ML properties in the app are extracted. If this switch is set, a comment is added in the generated XLIFF that specifies what the ID of the translation item would be in C/SIDE. This acts as a mapping that allows you to convert existing translation resources for your app.
–runtimeSpecify the target runtime for the converted AL. The default is the latest supported runtime. The string should be in a format similar to major.minor.
–objectFileNamePatternSpecify the pattern for naming AL files that contain AL objects by using the following placeholders: {name} – object name, {type} – object type, {id} – object ID. This parameter only takes effect if --rename is specified. The default is {name}.{type}.
–extensionObjectFileNamePatternSpecify the pattern for naming AL files containing AL extension objects by using the following placeholders: {name} – extension object name, {type} – extension object type, {id} – object ID, {targetName} – the name of the object being extended, {targetId} – the ID of the object being extended. This parameter only takes effect if --rename is specified. The default is {name}.{type}-{targetName}.
–formatFormat the converted AL code using the standard formatter.
–dataClassificationDefaultingSpecify the DataClassification property for all table fields that don’t have it specified. For more information, see DataClassification Property.
–tableDataOnlyFor table objects, specifies to convert only the table and field definitions, including properties. Methods and trigger code isn’t included. Note: This parameter was first introduced in Business Central version 14.2 (cumulative update 11) and Business Central version 15.5.

Although this tool can save you a lot of time, please note that there are still many problems that need to be fixed manually after the conversion.

Find out more about Txt2Al Conversion Tool from Microsoft Docs.


Hope this will help.

Thanks for reading.