Goodbye C/SIDE, welcome AL!

It was a long journey that led to the development of “Extensions V2” for Dynamics NAV. Those who have tried with events and then with the first extensions will remember the many attempts to make NAV “modular”, which by its nature is not “modular”.

Today, however, the wait is over and already with NAV 2018 anyone can experience the effectiveness of the new development system, without preview or “beta” products. The toolset is complete, stable and most importantly: it works! I have developed many customizations for NAV and some verticals in the past years. Like many partners we have an additional “layer” to the Italian localization including the most frequent requests made by customers, then we have the solution for retail, for pharmaceutical distribution and recently also for the automotive sector.

Well it was possible to port over 90% of all this code into the new extension system! This means minimally modifying the standard NAV database with great benefit for future updates. In other words it means reducing the effort for a release update from 100 to 10.

The editor

The new development environment is Visual Studio Code, a light (but innovative) version of the classic Visual Studio. A revolution for those used to the so-called “classic” but finally NAV has its own code editor, which produces files like any other language, fully integrated with Git for versioning.

In 2009, when I started working with NAV, I had more than 10 years of development in various OOP languages. It took me a while to get used to the fact that the code was inside the database and that there were no source files. It is no coincidence that before I even started my first project, I developed a tool to automatically extract code from the database and publish it in a central repository. At the time we used SVN and I even gave that tool away to other partners: for me it was inconceivable to work without code versioning.

From NAV to 365

The various rumors from last year were clarified by Microsoft on the occasion of the latest Directions in Madrid in October ’17. The topic was the migration of NAV towards a new product, exclusively cloud. Leaving aside the “on premises” vs cloud discussion, which is outside of this article, everyone’s concern was that of losing the possibility of customizing (even deeply) the tool.

Being well structured and easily modifiable is one of the keys to the success of NAV which has made it popular, reliable and transversal to many product sectors. Working with the “Extensions V2” and reaching the same level of effectiveness as the previous system certainly calms the souls and reassures those who want to continue developing for this magnificent platform even if it were just more cloud.

After some initial confusion, Microsoft’s strategy with Dynamics 365 is now quite clear. NAV already has its new name: “Dynamics 365 for Finance and Operations, Business Edition” and the underlying technology is that of NAV 2018!

Previewing and developing the new platform is possible. In fact, Microsoft periodically releases Dynamics 365 F&O software on Docker. Yes yes, just Docker: the famous open source image repository! This, if we want, is the obvious confirmation that at the base of 365 there are “on premises” technologies which will certainly be alternatives to the cloud offer alone. Just think of PowerBI: since the gateway for the use of local data became available, the tool went from being a “toy” to a valid and serious proposal for any type of company.

Change approach

Let’s take the example of the “Undo Sales Shipment Line” codeunit. As standard it is not possible to cancel the shipment of account lines (this can only be done for items). With the previous system it was obvious to open the source, comment out a few standard lines and integrate the lack with your own customized code.

Working with the “Extensions V2” instead forces you to take a better approach, more modular and fully compatible with a version update. We intercept the moment in which the user presses the “Cancel shipment” button, if the line is of the item type we proceed as per standard, if the line is of the account type the extended function starts. All this about the “OnBeforeAction” event.

Another innovative aspect is the use of dependencies to make not only NAV but also your solution modular.

Again to give examples, we have developed a support module for ODETTE communications (a version of Edifact specific for the automotive sector). This module, which was previously dispersed among various NAV objects to be merged each time, has been migrated into 4 “packages” linked together via dependencies. At the base there is “Essentials” extended with “Network” extended with “EDI” finally extended with “EDI Odette”.

The advantage? 4 separate projects, 4 libraries that grow independently, possibility to assign development to different teams. Trivia for those who develop with other languages and which are finally also available for NAV.

Tips & Tricks

I couldn’t end the article without a classic “tips & tricks”! The current version of Visual Studio Code cleans up the extension every time you compile. This means that if you have data in an extended table and you recompile it, you lose it every tim

This behavior is partly correct, because it allows you to always start an extension “clean”, but it is frustrating if you have sample data with which you are doing development. The team on Microsoft’s GitHub is very active and responsive to reported bugs, I trust that it will be resolved in future releases. In the meantime, we have developed a script in PowerShell to update the extension without losing data. It can easily be invoked from Visual Studio Code with a keyboard shortcut, practically transparently.

Import-Module "C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client\NavModelTools.ps1"

$app = Get-Content ''app.json'' | Out-String | ConvertFrom-Json
$fn = $app.publisher + "" + $app.name + "" + $app.version + ".app"

write-host "Install or upgrade"
write-host $app.name
write-host $app.publisher
write-host $app.version

Uninstall-NAVApp -ServerInstance DynamicsNAV110 -Name $app.name
Unpublish-NAVApp -ServerInstance DynamicsNAV110 -Name $app.name
Publish-NAVApp -ServerInstance DynamicsNAV110 -Path $fn -SkipVerification
Sync-NAVApp -ServerInstance DynamicsNAV110 -Name $app.name
Start-NAVAppDataUpgrade -ServerInstance DynamicsNAV110 -Name $app.name
Install-NAVApp -ServerInstance DynamicsNAV110 -Name $app.name

write-host "Upgrade completed"