Thursday 14 January 2016

How do I: Develop an Extension

You can build extension packages that add functionality to a Microsoft Dynamics NAV deployment.

For Overview, please see my earlier posts Introducing Extensions in Microsoft Dynamics NAV 2016

Like any common functionality you want to roll out to different locations of a same company maintaining Object Set Globally for their Navision deployment.

You can perform conventional Export object and send to different locations, where they import these objects in their databases. Another option is through Extensions. Specially very helpful in Tenant model deployment.

But do the limitations apply as we discussed in my earlier post:

[A] Which Object types you can Include & Restrictions applicable to C/AL code in Extension Packages

[B] Which Properties are Restricted in Extension Packages

Unlike the familiar development and deployment of Microsoft Dynamics NAV functionality, building an extension relies on the exported version of an application to .TXT files.

You can export the application from the development environment, use the development environment commands, or use the Windows PowerShell cmdlet that is available in the Microsoft Dynamics NAV 2016 Development Shell,
Export-NAVApplicationObject.

MS recommend that you create a folder structure that can be leveraged by the cmdlets that you use when you build the extension package. That structure should contain folders for the ORIGINAL object files, MODIFIED object files, and DELTA files. These names match those used as parameters in the application merge utilities.

Recall from my earlier post where we deled with Upgrading the Application Code in Microsoft Dynamics NAV 2016

We used folder structure for placing the objects before we performed action:
“In my example, the UpgradeDemo folder on the C drive contains five folders: ORIGINAL, MODIFIED, TARGET, DELTA, and RESULT. The DELTA and RESULT folders are empty. The ORIGINAL, MODIFIED, and TARGET folders contains one or more text files that contain application objects.”

Similar structure we will be using for creating package. You can follow same for easy reference or you can use your convenient naming convention and structure.

I will come back on this in my future post, what exactly structure I will be using for my walkthrough on Extension.

You can refer to cmdlets we discussed earlier for upgrade and extensions which will be used in rest of the parts of this and upcoming posts while dealing with Extensions.

[A] Helpful PowerShell Commands which you can use for Upgrade Process in Navision 2016

[B] Few Helpful PowerShell Commands which you can use for Upgrade Process in Navision 2016 – Part 2

[C] Useful Windows PowerShell cmdlets for managing Extensions in Dynamics Navision 2016

 

5 Steps To create an extension



  1. Establish the BASE as TXT files.




  • The foundation for your extension is the exported .txt files of the objects you are modifying.

  • You can export just the objects that you want to modify, or you can export the entire Microsoft Dynamics NAV application.

  • In the Microsoft Dynamics NAV 2016 Development Shell, the Export-NAVApplicationObject cmdlet can automate this process or you can use the export functionality in the development environment.

  • The following example uses this cmdlet to export objects to establish the base for the planned modifications.



Export-NAVApplicationObject -Path ORIGINAL -DatabaseName MyDatabase -DatabaseServer MyDatabaseServer


  • Objects must be exported as .TXT files. You cannot build an extension based on a .FOB file.

  • If you use a source control system, you may want to pull the base .TXT files from there.



  1. Create functionality in the development environment.




  • Use the development environment as usual to create new objects or modify ones to the extent your license allows you.

  • Also don’t forget to reference limitations with Extensions Property and Objects which you can include in Extensions, see above provided link for more details.

  • Keep in mind the following rules as discussed earlier:






  • DO NOT make C/AL code modifications

  • DO use subscribing to events to execute code.

  • DO NOT create new or modified XMLPorts, Queries, or Report.

  • DO NOT change restricted page and table properties.






  • In order to get an easy upgrade experience for your extensions, you cannot modify code the way you do in the traditional customization process.

  • Instead, you extend Microsoft Dynamics NAV functionality by subscribing to programming events that are raised either explicitly in code, or implicitly by the platform.

  • Test your application with the extension added.




  1. Export your changed and added application objects to .TXT files.




  • Export all objects that you added or modified to .TXT files.

  • Use the same export cmdlet from step 1 or manually export within the development environment.

  • They must also be exported as .TXT files and should be placed in a separate directory so that the packaging process can be pointed at them.



Export-NAVApplicationObject -Path MODIFIED -DatabaseName MyDatabase -DatabaseServer MyDatabaseServer


  1. Create DELTA files using the Microsoft Dynamics NAV 2016 Development Shell cmdlets.




  • Extension packages are based on application object deltas. Again, you use the application merge utilities in the Microsoft Dynamics NAV 2016 Development Shell to distil the changes in the form of application object differences that are stored in DELTA files.

  • Creating an extension uses many of the same concepts and tools as you know from application object deltas. You use the Compare-NAVApplicationObject cmdlet to create these delta files.



Compare-NAVApplicationObject -OriginalPath ORIGINAL -ModifiedPath MODIFIED -DeltaPath DELTA

Your delta files must be one-to-one with the objects you have added or modified. You cannot include a single merged delta file. If you output your export file as a single file use the Split-NAVAppplicationObjectFile cmdlet to create the individual files.

  1. Build the extension package.


 

I will come up with more details in my upcoming posts on this topic.

3 comments: