C/AL to AL Converters

With the C/AL to AL Converter tool you can convert your objects to AL files and create extensions.

C/AL to AL Converter
C/AL to AL Converter

  1. Setup
  2. Converter Card
  3. Add Objects
    1. Base Objects
    2. Action Type
  4. Check Guidelines
  5. Converter Actions
    1. Solve Breaking Changes
    2. Add Parentheses ()
    3. Add Missing Application Areas
    4. Add Missing Data Classifications
    5. Add Missing Usage Categories
    6. Prevent Conflicting Control Names
    7. Sort Variables
    8. Remove RunOnClient
    9. Replace StringBuilder
  6. Company Converters
  7. Breaking Changes
  8. Extract Subscribers
  9. Create Files
    1. dotnet File
    2. Permission File
    3. XLIFF Files
    4. SQL Scripts
  10. Update Properties
    1. Calculate No. and Names
    2. Get Object Nos. from Files
    3. Update File Names


Setup

There are a couple of settings in the Object Manager Setup that apply to the conversion tool. A new database type is added specially for the conversion task. It disables saving the fob version of each object to the history for better performance. And it enables conversion guideline checks.

Database Type Conversion
Database Type Conversion


Settings
Settings

Conversion Nos. FormatThis is the no. series format used when a new converter is created.
Extension File Name FormatSee chapter File Name Format for more information.
No. of Converter ActionsZoom in to see which actions are executed when you create the extension.

Settings
Settings


Converter Card

Fill in the fields on the converter card as follows:
No.The no. of the converter.
NameThe name of the converter.
Directory NameThe directory where the converted objects are saved.
ID Range Starts atSpecify the object numbers that must be assigned to the AL files.
PrefixThis prefix is added to the name of the objects. Add a space to the prefix if you want a space between the prefix and your object name.
Target TypeSelect the type of extension you want to create. Specific actions are enabled when choosing Cloud.
Target VersionSelect the BC version that your extension is meant for. Extra breaking changes will be added if you choose a higher version.
Remove CaptionsIf you want to work with XLIFF Files, your captions need to be removed from your AL Files. The actual XLIFF files are created with the button Create XLIFF Files on the actions ribbon.

Add Objects

To add the objects you want to convert, click Add Objects… in the ribbon and select the objects en press OK.

Add Objects
Add Objects


Base Objects

To convert modifications made to standard objects you can add the initial version of these objects. The delta is calculated and the changes are transferred to an extension object. Press Add Base Objects... to open the History Objects page and select all objects present in your Converter.

Add Base Objects
Add Base Objects

Action Type

Per object you can choose four action types:
<Empty>The object will be skipped.
ConvertObject will be converted.
Convert DeltaThe modifications will be calculated and an extension created.
DisableThe object will be skipped and all references will be removed in all other converted objects. This can be used if you have e.g. a page part with a control add-in that is not supported in the Web Client or a codeunit with functionality that is only suited for the Windows Client.

Action Type
Action Type


Check Guidelines

Press Check Guidelines to see which comments are found and you may want to consider solving before converting your objects to an extension.

See chapter Check Guidelines for more info.

Converter Actions

CodeName
100Solve Breaking Changes
101Add Parentheses ()
102Add Missing Application Areas
103Add Missing Data Classifications
104Add Missing Usage Categories
105Prevent Conflicting Control Names
106Sort Variables
107Remove RunOnClient
108Replace StringBuilder
900Company Converters

Solve Breaking Changes

Breaking changes that can be solved are fixed. Breaking changes like signature changes must currently still be fixed manually.

Add Parentheses ()

Parentheses are added after the most commonly known recordset functions. It's on the roadmap for OMA15 to update this action to handle all functions.

Add Missing Application Areas

Missing application areas are filled with value All.

Add Missing Data Classifications

Missing data classification properties are filled with the value CustomerContent.

Add Missing Usage Categories

Objects that have an ApplicationArea but not a UsageCategory. List type pages get the value Lists. All other pages the value Documents.

Prevent Conflicting Control Names

The AL ruleset will raise warnings if a control name has the same name as a variable. This action prevents this conflicts.

Sort Variables

The AL ruleset requires you to define your variables in a specific order. First recordsets than report, codeunits etc. This action sorts all variables in the required order.

Remove RunOnClient

The property runonclient on dotnet variables are removed.

Replace StringBuilder

In a cloud extension it is forbidden to use dotnet variables. If the target type of your converter is Cloud, all dotnet StringBuilder variables are changed to references to codeunit DotNet_StringBuilder and C/AL Code like SB := SB.StringBuilder; will be replaced with SB.InitStringBuilder('');

Company Converters

You can subscribe to two subscribers to write your company specific converters. The first is called InitializeConvertActions and is used to add the converter to the converter list.


LOCAL [EventSubscriber] InitializeConvertActions(VAR Sender : Codeunit "OM - AL Converter")
Sender.AddCompanyAction(900, TxtThisIsAnExampleAction);


In this example we chose 900 for the unique ID of the converter.

The second subscriber is called AfterConvertObject and will execute the actual converter.


[EventSubscriber] AfterConvertObject(VAR Sender : Codeunit "OM - AL Converter";VAR TmpObject : TEMPORARY Record "OM - Object";VAR TmpElement : TEMPORARY Record "OM - Element";VAR TmpProperty : TEMPORARY Record "OM - Property";VAR TmpCaption : TEMPORAR
IF Sender.ActionEnabled(900) THEN
  IF TmpObject.Name = 'PRE Example Codeunit' THEN
    IF TmpProcedure.GetByName(TmpObject."Entry No.", 'ExampleProcedure') THEN
      TmpProcedure.CommentLines(5, 10);


The above example will comment out some C/AL code in the procedure ExampleProcedure in codeunit PRE Example Codeunit.

Breaking Changes

Microsoft is refactoring the base app every release. Therefore, procedures moves regularly to other codeunits and are renamed etc. These changes can break your app. E.g. in BC13 all functions in codeunit 1 were moved to separate codeunits. OMA can solve a lot of these breaking changes. Zoom in on the field No. of Breaking Changes to see which changes OMA will fix.

Breaking Changes
Breaking Changes

Extract Subscribers

Modifications on specific triggers can be moved to events. If you have written some code on e.g. the OnInsert trigger of a table it will also be executed if you create a subscriber on the event OnAfterInsertEvent. An example of such a subscriber could look like this:


LOCAL [EventSubscriber] CustomerOnInsert(VAR Rec : Record Customer;RunTrigger : Boolean)
IF RunTrigger THEN
  WITH Rec DO BEGIN
    MESSAGE('Inserted code');


Use the Extract Subscribers... button in the action ribbon to open the page that can create this subscribers.
All pages and tables with a base object are added to the page.

Extract Subscribers
Extract Subscribers

No. of Source FilesZoom in to see which objects will be scanned for code that can be moved to subscribers.
Remove from Source ObjectsThe triggers with extracted code are rolled back to the version of the base object.
TypeChoose where the subscribers must be saved. Possible options are:
  • Database - an object will be added/updated in the database.
  • C/AL File - a file in C/AL format will be saved/updated on your file system.
  • AL File - an AL file will be saved/updated in your VS Code project.
Codeunit No.The number of the codeunit.
Codeunit NameThe name of the codeunit
File NameThe name of the file

Create Files

Create Files
Create Files


dotnet File

Press this button to create the dotnet file. All your objects will be scanned and all dotnet references will be placed in the dotnet file.

dotnet
{

    assembly("System.Web")
    {
        Version = '4.0.0.0';
        Culture = 'neutral';
        PublicKeyToken = 'b03f5f7f11d50a3a';

        type("System.Web.HttpUtility"; "HttpUtility")
        {
        }
    }

    assembly("System.Xml")
    {
        Version = '4.0.0.0';
        Culture = 'neutral';
        PublicKeyToken = 'b77a5c561934e089';

        type("System.Xml.XmlDocument"; "XmlDocument")
        {
        }
    }

}


Permission File

Press this button to create the permissions file.

<?xml version="1.0" encoding="utf-8"?>
<PermissionSets>
  <PermissionSet RoleID="CarApp" RoleName="CarApp">
    <Permission>
      <ObjectType>TableData</ObjectType>
      <ObjectID>60002</ObjectID>
      <ReadPermission>Yes</ReadPermission>
      <InsertPermission>Yes</InsertPermission>
      <ModifyPermission>Yes</ModifyPermission>
      <DeletePermission>Yes</DeletePermission>
      <ExecutePermission>Yes</ExecutePermission>
      <SecurityFilter />
    </Permission>
    <Permission>
      <ObjectType>TableData</ObjectType>
      <ObjectID>60003</ObjectID>
      <ReadPermission>Yes</ReadPermission>
      <InsertPermission>Yes</InsertPermission>
      <ModifyPermission>Yes</ModifyPermission>
      <DeletePermission>Yes</DeletePermission>
      <ExecutePermission>Yes</ExecutePermission>
      <SecurityFilter />
    </Permission>
  </PermissionSet>
</PermissionSets>


XLIFF Files

Press this button to create the XLIFF files.


<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file datatype="xml" source-language="en-US" target-language="en-US" original="translation">
    <body>
      <group id="body">
        <trans-unit id="TableExtension 1056305832 - Property 2879900210" size-unit="char" translate="yes" xml:space="preserve">
          <source>Customer</source>
          <target>Customer</target>
          <note from="Developer" annotates="general" priority="2"></note>
          <note from="Xliff Generator" annotates="general" priority="3">TableExtension CAR Customer - Property Caption</note>
        </trans-unit>
        <trans-unit id="TableExtension 1056305832 - Field 3892782271 - Property 2879900210" size-unit="char" translate="yes" xml:space="preserve">
          <source>Car Code</source>
          <target>Car Code</target>
          <note from="Developer" annotates="general" priority="2"></note>
        <note from="Xliff Generator" annotates="general" priority="3">TableExtension CAR Customer - Field Car Code - Property Caption</note>
        </trans-unit>


SQL Scripts

Press this button to create a file with SQL statements. With these statements you can copy your data to your extension database.


--DELETE FROM [DATABASENAME].dbo.[Object Manager Advanced 14_00$Customer$6BDBE989-9EBE-4A66-B514-EDEF89FCF142];

INSERT INTO [DATABASENAME].dbo.[Object Manager Advanced 14_00$Customer$6BDBE989-9EBE-4A66-B514-EDEF89FCF142]([No_], [Car Code])
SELECT [No_], [Car Code]
FROM [Object Manager Advanced 14_00$Customer];

GO

--DELETE FROM [DATABASENAME].dbo.[Object Manager Advanced 14_00$Sales Header$6BDBE989-9EBE-4A66-B514-EDEF89FCF142];

INSERT INTO [DATABASENAME].dbo.[Object Manager Advanced 14_00$Sales Header$6BDBE989-9EBE-4A66-B514-EDEF89FCF142]([Document Type], [No_], [Car Code])
SELECT [Document Type], [No_], [Car Code]
FROM [Object Manager Advanced 14_00$Sales Header];

GO

Update Properties

Calculate No. and Names

If you change the prefix or object range the object numbers and names must be updated. Press the action Calculate No. and Names and the new prefix and/or object range will be applied.

Get Object Nos. from Files

When you start working on an existing extension, the object numbers in your converter need to be the same as the object numbers in your VS Code project. To synchronize these values press Get Object Nos. from Files. The link is made with the object names so the Ext. Object Names and the object names in your AL files must be the same.

Update File Names

If you change an Ext. Object Name you need to change the name of the AL file as well. Otherwise, the converter makes a second file for the same object. The button Update File Names will rename the files in your VS Code project according to the format specified in the setup. More info: File Name Format