Converting from cal to al in VS Code

Converting from cal to al in VS Code

Converting from C/AL to AL can be a bit of a hassle:

  • First you need to open den Development Environment
  • Then filter the objects that needs converting
  • Export the objects to a txt file in a folder
  • Then Run the Txt2AL.exe
  • Lastly import them in the workspace

But that doesn’t work, because the syntaxes of many the properties will be wrong and the export will demand a lot of work afterwards.

So, I thought: Why cannot I do that directly from VS Code?

Searching the Internet, it seems that a lot of other people have struggled with the same issue so I decided to compile a PowerShell script that can be run directly from VS Code.

This should work:

Notice there is also a script to create delta files from changed objects. The procedure here is:

  1. Export a standard object from C/Side. The objects must have all the same add-ons as in the changed object. Name the file standard.txt
  2. Export the changed objects as text. Name the file changed.txt.
  3. Add the two files to the cal
  4. Run the command Compare-NAVApplicationObject, which will create delta files
  5. Then run the txt2al command, which will create:
    1. PageExtensions
    2. TableExtensions

Just remember:

  • start VS Code as administrator
  • load the PowerShell extension.
  • Create a couple of folders
    • c:\temp
    • c:\temp\AL
    • c:\temp\AL\cal
    • c:\temp\AL\al

And of course, change the connection details and filters.

Then just mark the code and press F8 to run the code.

The Script can be downloaded here:

As usual, use at own risk

Leave a Reply

Your email address will not be published. Required fields are marked *