navision 2015

Creating and Using a Client Control Add-in –Bing Maps for Dynamics NAV

This walkthrough demonstrates how to create a Microsoft Dynamics NAV control add-in and use it on a Microsoft Dynamics NAV page. A client control add-in enables you to add custom functionality to the Microsoft Dynamics NAV Windows client and the Microsoft Dynamics NAV Web client by creating a control add-in that can run on both client platforms.

This walkthrough addresses the Microsoft Dynamics NAV implementation of extensibility. This makes it possible to write control add-ins for all display targets. For information about how to write control add-ins specifically for Microsoft Dynamics NAV Windows client, see Extending the Windows Client Using Control Add-ins.

In a typical business scenario, developers create control add-ins using Microsoft Visual Studio Express, or Visual Studio 2013. Implementers of Microsoft Dynamics NAV solutions then use the control add-ins on Microsoft Dynamics NAV client pages, such as the Microsoft Dynamics NAV Windows client, the Microsoft Dynamics NAV Web client, or the Microsoft Dynamics NAV Tablet client.


To complete this walkthrough, you will need:

  • Microsoft Dynamics NAV with a developer license. For more information, see System Requirements for Microsoft Dynamics NAV 2016.
  • CRONUS International Ltd. demonstration database.
  • Microsoft Visual Studio Express or Microsoft Visual Studio 2013.
  • Microsoft .NET Strong Name Utility (sn.exe). This is included with Windows SDKs.
  • Experience using Visual Studio.


Simon is a software developer working for CRONUS International Ltd. He has been told that the users of the Microsoft Dynamics NAV Web client want to see Bing Maps displayed on the Web client. He wants to use the client extensibility framework to test how to do this on a separate page first.

Creating a Control Add-in With Visual Studio

Microsoft Dynamics NAV includes the Microsoft.Dynamics.Framework.UI.Extensibility.dll assembly that defines the model for creating Microsoft Dynamics NAV control add-ins. The Microsoft Dynamics NAV API provides the binding mechanism between the Microsoft Dynamics NAV control add-in and the Microsoft Dynamics NAV framework.

To create the control add-in

  • In Visual Studio, on the File menu, choose New, and then choose Project.
  • Under Installed Templates, choose Visual C#, and then choose Class Library.
  • In the Solution Name text box, enter the name of your solution. For example, you can enter BingMapsControlAddIn and then choose the OK button.
  • You will add a reference to the following assembly: Microsoft.Dynamics.Framework.UI.Extensibility.dll
  • In Solution Explorer, right-click your project, and then choose Add Reference.
  • In the Add Reference window, on the Browse tab, navigate to the location of the Microsoft.Dynamics.Framework.UI.Extensibility.dll assembly on your computer, and then choose the OK button. By default, the path of the assembly is C:\Program Files (x86)\Microsoft Dynamics NAV\90\RoleTailored Client.
  • Open the Class1.cs file and add the following using directive.
  • using Microsoft.Dynamics.Framework.UI.Extensibility;
  • In the BingMapsControlAddIn namespace, add the following code to declare a new interface named BingMapsControlAddIn.

namespace BingMapsControlAddIn



public interface IBingMapsControlAddIn



event ApplicationEventHandler ControlAddInReady;


event ApplicationEventHandler MapLoaded;


void LoadMap(double latitude, double longitude);


void ShowMiniMap(bool show);


void ShowPushpin(string title, string imageName);



  • You will use the name BingMapsControl later in the walkthrough when you register the control add-in in Microsoft Dynamics NAV.

The assembly must now be signed to be used with Microsoft Dynamics NAV. The next steps will discuss how to sign the assembly.

To sign the assembly

  1. In Visual Studio, on the Project menu, choose BingMapsControlAddIn properties.
  2. In the Properties window, choose Signing, and then select the Sign the assembly check box.
  3. In the Choose a strong name key file drop-down list, select New.
  4. In the Key file name text box, enter BingMapsControlAddIn, and then clear the Protect my key file with a password check box.
  5. Choose the OK button.
  6. In Solution Explorer, notice the BingMapsControlAddIn.snk file that is added in Solution Explorer.
  7. On the Build menu, choose Build <Your Solution> to build the project. Verify that the build succeeds.

Copying the Control Add-in Assembly to the Microsoft Dynamics NAV Development Environment

After you build the control add-in, you copy the output assembly file to the computer that is running the development environment.

To copy the control add-in assembly to the Microsoft Dynamics NAV Development Environment

  1. On the computer, locate and copy the control add-in assembly file (.dll) file in the control add-in project’s output folder.
  2. By default, this folder is C:\Documents\MyDocuments\Visual Studio\Projects\[Your Addin Project]\[Your Class Library]\bin\Debug.
  3. On the computer that is running the development environment, paste the assembly in the Add-ins folder.

    By default, this folder is C:\Program Files (x86)\Microsoft Dynamics NAV\90\RoleTailored Client\Add-ins.

Creating the Manifest File

After you create an interface in Visual Studio that exposes a number of properties for the BingMapsControlAddIn, you must create a manifest file. A manifest file is written in XML and contains information such as where to look for resource files, references to external JavaScripts, and the size of the control add-in. For more information, see Manifest Overview. In the next steps, you will create a manifest file that loads a BingMaps control and you will register this manifest in the Client Add-in page.

To create the manifest file

  • Copy this sample manifest and paste it into any text editor.

<?xml version=”1.0″ encoding=”utf-8″?>







Microsoft.Dynamics.NAV.InvokeExtensibilityMethod(‘ControlAddInReady’, null);









Save the manifest to a file that is in same directory that the assembly is saved in, the Add-ins directory.

Name the manifest Manifest and make sure to add the .xml extension to the file, so that the file name will now be Manifest.xml.

The next step is to create a JavaScript file containing code that calls C/AL in Microsoft Dynamics NAV.

Creating a JavaScript File

Now you must create a JavaScript file to hold all of the code that calls C/AL in Microsoft Dynamics NAV.

To create the JavaScript file

  1. Copy this sample script and paste it into any text editor.
  2. var map = null;
  3. function InitializeMap(controlId) {
  4. map = new VEMap(controlId);
  5. map.HideScalebar();
  6. map.onLoadMap = function () {
  7. Microsoft.Dynamics.NAV.InvokeExtensibilityMethod (‘MapLoaded’, null);
  8. };
  9. }
  10. function LoadMap(latitude, longiture) {
  11. var mapOptions = new VEMapOptions();
  12. mapOptions.DashboardColor = “black”;
  13. mapOptions.EnableSearchLogo = false;
  14. map.LoadMap(
  15. new VELatLong(latitude, longiture), // Center
  16. 1, // Zoom level 1-19
  17. VEMapStyle.Birdseye, // Map style
  18. false, // Fixed map
  19. VEMapMode.Mode2D, // Map mode
  20. true, // Map mode switch
  21. 0, // Tile buffer
  22. mapOptions // Options
  23. );
  24. }
  25. function ShowMiniMap(show) {
  26. if (show)
  27. map.ShowMiniMap();
  28. else
  29. map.HideMiniMap();
  30. }
  31. function ShowPushpin(title, imageName) {
  32. map.Clear();
  33. if (title != ”) {
  34. var point = map.GetCenter();
  35. var pushpin = map.AddPushpin(point);
  36. pushpin.SetTitle(title);
  37. }
  38. }
  39. Save and name the script Script and make sure to add the .js extension to the file, so that the file name will now be Script.js.

The next step is to create a .zip file containing the manifest and resource files and register this file with the control add-in in Microsoft Dynamics NAV.

Creating a Resource .Zip File

Before registering the control add-in in Microsoft Dynamics NAV, you must create one single file containing the manifest and any resource files. This single file is a .zip file and it will be registered in the Client Add-in page. The .zip file must contain a certain structure for it to be recognized by the Client Add-in page. In the next steps, you will create the right structure and a .zip file.

To create a resource .zip file

  1. On your computer, in a folder of your own choice, create the following folder structure: ImageScript, and StyleSheet.
  2. Locate the Manifest.xml file that you created in the previous steps, and copy this to the same folder structure. Then locate the Script.js file that you created in the previous steps, and copy this to the Script folder. Your folder should now look like this:

  3. Place images, scripts, and stylesheets in the right folders, but in this walkthrough we will leave the rest of these folders empty.
  4. In the Windows Explorer mark all of the folders and the manifest file and right-click, and then choose Send to…, and then choose Compressed (zipped) folder.
  5. Name the .zip file BingMapsControlAddIn.

Registering the Control Add-in in Microsoft Dynamics NAV

To register a control add-in, you include it in the Control Add-in page in Microsoft Dynamics NAV. To include a control add-in in the page, you must provide the following information:

  • Control Add-in name.The control add-in name is determined by theMicrosoft.Dynamics.Framework.UI.Extensibility.ControlAddInExport attribute value of control add-in class definition that you specified when you created the control add-in. The name in this walkthrough is BingMapsControl.
  • Public key token.This is a 16-character key that is given to the assembly when it is signed and built in Visual Studio. You can determine the public key token by running the Microsoft .NET Strong name Utility (sn.exe) on the assembly. You must run the utility from the Visual Studio command prompt. The sn.exe utility is available with Visual Studio.
  • Resource.On the Control Add-in page, the Resource field is a BLOB data type and the content of the field cannot be viewed from the development environment.When this field is filled in, Microsoft Dynamics NAV identifies the registered control add-in as a type of control add-in that works on all display targets.

To determine the public key token for the control add-in

  1. On the Windows taskbar, choose Start, choose All Programs, choose Microsoft Visual Studio 2013, choose Visual Studio Tools, and then choose Developer Command Prompt for VS2013 to open the command prompt.
  2. At a command prompt, change to the directory that contains the assembly that you copied. For example, C:\Program Files (x86)\Microsoft Dynamics NAV\90\RoleTailored Client\Add-ins.
  3. Type the following command: sn –T <assembly>

    Replace <assembly> with the assembly name, such as BingMapsControlAddIn.dll.

  4. Press Enter and note the public token key that is displayed.

To include the control add-in in the Control Add-in page

  1. Open Microsoft Dynamics NAV.
  2. In the Search box, enter Control Add-ins and then choose the related link.
  3. In the Control Add-ins window, choose New, and then in the Control Add-in Name column, enter the control add-in name. In the Public Key Token column, enter the public key token that you obtained earlier.

With the Control Add-in window still open, you will now import the .zip file for the BingMapsControlAddIn add-in.

To include the .zip file in the Control Add-in page

  1. Choose Import.
  2. In the Import Control Add-in Resource window, locate the file that you saved earlier, and then choose Open.
  3. Choose the OK button to close the Control Add-in page.

Creating a Page to Display the Control Add-in

You have set up the prerequisites for using a control add-in from a page. Now you need a way to display the BingMapsControlAddIn control. In this section, you will create a new page called Bing Maps that contains two fields to control the coordinates of the map and one field that contains the map control. This involves the following tasks:

  • Creating a new page called Bing Maps.
  • Setting variables and properties.
  • Adding C/AL triggers.

To create the Bing Maps page

  1. In the Microsoft Dynamics NAV Development Environment, in Object Designer, choose Page, and then choose New.
  2. In the New Page dialog, choose Create blank page and then choose the OK button.
  3. In Page Designer, on the first line, in the Name column, enter Control1, and go to the next line.
  4. In the Type column, choose Group, and in the Caption column, enter Coordinates.
  5. On a new line, in the Type column, choose Field. In the Name column, enter LatitudeControl, and in the Caption column, enter Latitude.
  6. On a new line, in the Type column, choose Field. In the Name column, enter LongitudeControl, and in the Caption column, enter Longitude.
  7. On a new line, choose Group, and in the Caption column, enter Map.
  8. On a new line, under the Map group, for the Type column set to Field, in the Name column, enter Bing Maps Control.

    Your page design should now look like this.

  9. Save and compile the page. Name the page Bing Maps.

Now you have created a page skeleton. The next step is to add code and call the control add-in from a control on the page.

To add variables and properties

  1. In the Microsoft Dynamics NAV Development Environment, in Object Designer, choose Page, and then choose the Bing Maps page.
  2. On the Tools menu, choose View, and then C/AL Globals.
  3. On the Variables tab, enter Latitude in the Name column, and set the DataType to Decimal.
  4. Create a new variable. Enter Longitude in the Name column, and set the DataType to Decimal.
  5. Create a new variable. Enter MiniMap in the Name column, and set the DataType to Boolean.
  6. Close the C/AL Globals window.
  7. In Page Designer, on LatitudeControl, set SourceExpr to Latitude in the C/AL Symbol Menu.
  8. On LongitudeControl, set SourceExpr to Longitude in the C/AL Symbol Menu.
  9. Select the BingMapsControl field, and then on the View menu, choose Properties.
  10. In the Properties window, locate the ControlAddIn property and choose the Up Arrow. Select the BingMapsControl control add-in from the Client Add-in window.
  11. Choose the OK button to close the Client Add-In window. The public key token is inserted into the Value field. Close the Properties window.

To add C/AL triggers

  1. With the Bing Maps page open in Object Designer, on the View menu, choose C/AL Code.
  2. In the Page Bing Maps – C/AL Editor window, locate the BingMapControl::ControlAddInReady() trigger, and add the following line of code.
  3. CurrPage.BingMapControl.LoadMap(Latitude, Longitude);
  4. In the Page Bing Maps – C/AL Editor window, locate the BingMapControl::MapLoaded() trigger, and add the following line of code.
  5. CurrPage.BingMapControl.ShowMiniMap(MiniMap);
  6. Finally, locate the OnInit() trigger, and add the following line of code.
  7. Latitude := 40.689467;
  8. Longitude := 74.044444;
  9. Save and compile the Bing Maps page.

After you have saved and compiled the Bing Maps page, you can run the page directly from the development environment to verify that it works on the Microsoft Dynamics NAV Web client.

Above script is copied from

And Thanks to Vjeko

To download the file please use below link!AjsNk_xi_lgtgqFy4zG2b0fRB-0lZw

navision 2015

How to Create and use Self-signed SSL Certificate for Dynamics NAV


  • This article explains how to create an SSL certificate for a Test environment.
  • For a Live environment, you must purchase SSL certificate from a certification authority, for example ComodoSymantecDigicert, etc.
  • Keep a copy of Certificate Thumbprint and a copy of the Certificate generated.


Download Self-signed certificate generator (PowerShell).

Create SSL Certificate

  1. Open Windows Powershell ISE – Run as administrator
  2. Know you Execution Policy:
    1. The following command gets the current execution policy: Get-ExecutionPolicy
    2. If it is Restricted, change the Execution Policy, for example in this case: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

  1. Go to the location where you saved the New-SelfSignedCertificateEx.ps1 file.
  2. Run the following command:
    Import-Module .\New-SelfSignedCertificateEx.ps1

  1. Run the following command, where you can find the <Full Computer Name> from system properties:
    New-SelfSignedCertificateEx –Subject “CN=<Full Computer Name>” –IsCA $true –Exportable –StoreLocation LocalMachine

  1. Copy and Save the Thumbprint for later use.

Manage Certificate

  1. Open Microsoft Management Console (mmc.exe)

  1. Click FileAdd/Remove Snap-in
  2. Select Certificates
  3. Click Add
  4. Select the Computer Account
  5. Click Finish and OK

Locate the Certificate

Now you can locate the Certificate under: Console RootCertificates (Local Computer)PersonalCertificates.

  • The name will be same as your service tier Machine.The Expiration Date Will be 1Y-2D (01 Year – 02 Days) for that certificate and it will be valid from 01 Day Before you create Certificate.

Assign Permissions to Certificate

  1. Right Click on the certificate.
  2. Click All TasksManage Private Keys
  3. Add Permission for the Account which is used to Run Dynamics NAV Services.

Copy and Paste Certificate

  1. Copy the Certificate from PersonalCertificates node.
  2. Paste the certificate into the Trusted Root Certification AuthoritiesCertificates node.

Download and Save the Certificate

  1. Right-click and Export the certificate

  1. Select the No, do not export the private key option

  1. Choose Next
  2. Select DER encoded binary x.509 (.cer)

  1. Specify a File Name and Finish the wizard. For example, here we have saved it as “NAV_Certificate.cer”.

  1. Copy and Save the certificate for later use.