Hi guys, today I am here with another interesting article which is about “How to create your extensions in Microsoft Dynamics NAV”. Extensions in Dynamics NAV is relatively a new concept but trust me, it is a cool thing.
So, the today’s agenda is
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. If you have miss that topic you can read about it here.
- 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.
Demo to create your first extension
- Make a backup of your database before doing any changes.
- Develop 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:
- 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 app like app name, publisher name, version etc. To do this:
- New-NAVAppManifest -Name “SYNERGY-IT” -Publisher “Zohaib Ahmed” -Version “18.104.22.168” | New-NAVAppManifestFile -Path “C:\Users\zohaib.ahmed\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\zohaib.ahmed\Desktop\Extensions file\MyFirstExtension.navx” -SkipVerification
- Its time to install your extensions. To do this:
- Install-NAVApp -ServerInstance DynamicsNAV100 -Name “SYNERGY-IT” -Version 22.214.171.124
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 created your first extension in Dynamics NAV.
To Download the powershell script (used to create an extension) : Click Here
To Download the Complete demo files (including folder): Click Here
Appendix (Demo Folder Directory Structure)
- “Combined files” folder contain the exported Standard and Customized Developed objects.
- “Delta folder” contain the differences in the standard and customized objects.
- “Development original files” contains the splitted customized objects (one object per file).
- “Standard original files” contain the splitted standard objects (one object per file).
I hope you got the basic concepts of how to develop an extension. If you have any question/confusion/query feel free to comment on post. If you like my article then don’t forget to share it.