Extension is a new approach of development in Dynamics NAV. It is introduced in Dynamics NAV 2016. The main idea behind extensions is to ship the customization without actually modifying the standard objects/code. This approach leads us to easy upgrade as we are only merging the code which is changed by Microsoft.
Extensions works on the top of Delta files. If you remember from the Upgrade process, Delta files are the files which are generated as a result of comparison i.e. comparison of Standard Object with the modified (customized) object. The same approach is used in extensions.
Before actual development, don’t forget to make the backup of your original database.
- Before moving ahead, the prerequisite of this walkthrough is you have fair idea of the concept of Events in Dynamics NAV.
- Basic knowledge of Powershell, as mostly process of extension can be done via PowerShell.
- You must have the original (standard) database on the version you are working.
- Delta files generated as a result of comparison of two or more text files so make sure you have the backup of NAV Standard Application Objects .txt format. If not, export them via NAV development environment.
- Make a backup of your database before doing any changes.
- Apply the changes you want to ship with your extensions. For example, I am adding the field say “Super Cool Customer” of type Boolean in the Customer table. Also, I am adding this field on Customer Card Page and Customer List Page. I am also creating a table 50000 say “Customer Comments” having fields “Customer No.” and “Comments” as shown in the screenshot below:
- After implementing the required functionality, add the Upgrade Codeunit for your extension. It is mandatory to add this codeunit after MS Dynamics NAV 2016. This upgrade codeunit will contain the code when you upgrade your extension. Below is the simple process to create the upgrade codeunit:
- Create a new codeunit say 50001 with the name “My Extension Upgrade CodeUnit”.
- Declare two functions in the Globals of your codeunit with the name:
- Make sure these functions are global.
- You are ready to publish your first extensions. To publish the extension first of all you have to export the modified objects in .txt files. However, it is recommended to compare the whole database but for now it is ok, to compare only the modified objects.
- After step 4, you should have two text files
- StandardObjects.txt containing all the standard object of NAV.
- ModifiedObjects.txt containing all the customized/modified objects.
- Now open PowerShell ISE as administrator.
- The basic idea, is to split the exported txt files into individual files. To do this you can use powershell command:
- Split-NAVApplicationObjectFile -Source "SourceFilePath.txt" -Destination "DesitnationPath" -Force
- After splitting compare these files one by one, which leads to the generation of Delta Files. These Delta files are nothing, but the changes in the two files. To do this:
- Compare-NAVApplicationObject -OriginalPath "OriginalPath" -ModifiedPath "Modified Path" -DeltaPath "Delta Files Path" -Force
- Once the Delta files have been generated, its time to generate the manifest file. Manifest file contains the information of the publisher, version etc. To do this:
- New-NAVAppManifest -Name "MyCompany" -Publisher "Zohaib Ahmed" -Version "126.96.36.199" | New-NAVAppManifestFile -Path
- "C:\Users\Username\Desktop\Extensions file\Manifest.xml" -Force
- After the manifest file has been generated, it’s time to publish your first extension (.NAVX) package. To do this:
- Get-NAVAppManifest -Path "ManifestFilePath.xml" | New-NAVAppPackage -Path "NAVX Package Path" -SourcePath "Delta Files Path"
- Publish-NAVApp -ServerInstance DynamicsNAV100 -Path "C:\Users\UserName\Desktop\Extensions file\MyFirstExtension.navx" -SkipVerification
- Its time to install your extensions. To do this:
- Install-NAVApp -ServerInstance DynamicsNAV100 -Name "MyCompany" -Version 188.8.131.52
Once installed successfully, you are able to see the new fields on the customer card page in the Windows client (as shown in the screenshot):
Congratulations! You have successfully created your very own first extensions for Dynamics NAV.
To download the sample files of this post: Click here
To download the power shell script used to publish the extension: Click here
If you have any query/issue/feedback, feel free to contact me. :)