Before we get started, it's important to see what we're converting. Our extremely simple CAL solution consists of two modifications to the Item Card:
- A new field named My CAL Table Code is shown after the Description field:
A new action named My CAL Action is shown after Save as Template:
Extract ch5-convert-cal-to-al-start.zip to a folder on your machine. You should have the following folders:
- \modifiedCal
- \alProject
- Using NavContainerHelper, we need to export the original unmodified CAL objects from the Dynamics NAV 2018 container. This gives us a baseline to compare our modified CAL objects to later on.
Open PowerShell ISE in administrator mode, and enter the following code into a new script. Make sure you change the name of the container based on what you have created:
$containerName = 'nav2018'
$conversionFolder = 'c:\programdata\navcontainerhelper
\extensions\' + $containerName + '\my\convert'
$originalFolder = Join-Path $conversionFolder "\original"
Export-NavContainerObjects -containerName $containerName -objectsFolder $originalFolder -filter "" -ExportTo "txt folder (new syntax)"
Save the script as 1-ExportBaseCalObjects.ps1 and then run it.
- From the extracted files, import \modifiedCal\modifiedCalObjects.fob into your Dynamics NAV 2018 system using the C/SIDE development client:
- Select Tools | Object Designer.
- Select File | Import... and select the \modifiedCal\modifiedCalObjects.fob file.
- Click Open.
- Click Yes to import all the objects.
- Select Later on the Synchronize Schema dialog and click OK.
- Click OK one more time to complete the process.
- In Object Designer, if you filter on all modified objects, you should see the following:
- Before we can convert CAL objects, we need to get them into a format that the conversion tool can understand. To do that, we need to export them to text. We'll do that with NavContainerHelper.
Open PowerShell ISE in administrator mode, and enter the following code into a new script. Again, make sure you change the container name accordingly:
$containerName = 'nav2018'
$conversionFolder = 'c:\programdata\navcontainerhelper
\extensions\' + $containerName + '\my\convert'
$modifiedFolder = Join-Path $conversionFolder "\modified"
Export-NavContainerObjects -containerName $containerName -objectsFolder $modifiedFolder -exportTo "txt folder (new syntax)" -filter "Modified = Yes"
Save the script as 2-ExportModifiedCalObjects.ps1 and then run it.
- Now that we have a folder with all of the unmodified objects, we need to get rid of the ones that our solution didn't modify.
Open PowerShell ISE in administrator mode, and enter the following code into a new script. Remember to change the container name accordingly:
$containerName = 'nav2018'
$conversionFolder = 'c:\programdata\navcontainerhelper
\extensions\' + $containerName + '\my\convert'
$originalFolder = Join-Path $conversionFolder "\original"
$modifiedFolder = Join-Path $conversionFolder "\modified"
$myOriginalFolder = Join-Path $conversionFolder "\myOriginal"
Create-MyOriginalFolder -originalFolder $originalFolder -modifiedFolder $modifiedFolder -myoriginalFolder $myOriginalFolder
Save the script as 3-RemoveUnmodifiedCalObjects.ps1 and then run it.
- We need to determine what changes we made to the original objects. Surprise! There's a NavContainerHelper command for that!
Open PowerShell ISE in administrator mode, and enter the following code into a new script. Remember to change the container name accordingly:
$containerName = 'nav2018'
$conversionFolder = 'c:\programdata\navcontainerhelper
\extensions\' + $containerName + '\my\convert'
$modifiedFolder = Join-Path $conversionFolder "\modified"
$myOriginalFolder = Join-Path $conversionFolder "\myOriginal"
$deltaFolder = Join-Path $conversionFolder "\delta"
Create-MyDeltaFolder -containerName $containerName -modifiedFolder $modifiedFolder -myDeltaFolder $deltaFolder -myOriginalFolder $myOriginalFolder -useNewSyntax
Save the script as 4-CreateCalDeltaFiles.ps1 and then run it.
- Now that we have our CAL objects in the proper format, we can do the conversion. Once again, we'll use NavContainerHelper to do this.
Open PowerShell ISE in administrator mode and create a new script with the following code:
$containerName = 'nav2018'
$conversionFolder = 'c:\programdata\navcontainerhelper
\extensions\' + $containerName + '\my\convert'
$deltaFolder = Join-Path $conversionFolder "\delta"
$resultFolder = Join-Path $conversionFolder "\result"
Convert-Txt2Al -containerName $containerName -myAlFolder $resultFolder -myDeltaFolder $deltaFolder -startId 50000
Save the script as 5-ConvertCalDeltaToAl.ps1 and then run it.
You should have the following files in your result folder:
- Now, it is time to create a new AL project where we can put our newly converted AL files:
- In Visual Studio Code, open the alProject folder that you extracted at the start of this recipe.
- Connect the AL project to your AL development sandbox. You can copy and adjust the launch.json file from the Television Show project or you can refer back to Chapter 1, Let's Get the Basics Out of the Way, and its first recipe, Setting up your development sandbox, for how to do this.
- Download the symbols for your new project.
- Copy the converted AL files from the result folder in step 7 to the alProject folder.
You should now have an AL project with the following contents:
- Let's try out our new Business Central application! Press F5 to build and deploy it to your AL development sandbox.
Go to the Item List page, select any item record in order to open the Item Card, and look for the following modifications that were converted from the CAL solution:
- The My CAL Table Code field shown after the Description field
- The My CAL Action action shown after Save as Template