In Microsoft Dynamics NAV 2013 R2, the Microsoft Dynamics NAV Web client now also supports extensibility, enabling control add-ins that display, for example, a chart or a map.
This means that you can write new control add-ins that you can use on both the Windows client and on the Web client. The following tutorial will walk you through the steps of creating a Hello World example that displays on the Web client.
To complete the following steps, you will need:
// This code is released under the terms of the Microsoft Public License (MS-PL,.)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Dynamics.Framework.UI.Extensibility;
namespace HelloWorld
{
public class Class1
{
[ControlAddInExport("HelloWorld")]
public interface iHelloWorld
{
[ApplicationVisible]
event ApplicationEventHandler ControlAddInReady;
}
}
}
In Visual Studio, on the Project menu, choose ClassLibrary Properties, and then choose Signing. Select the Sign the Assembly check box and choosea strong name key file.
Now build the project.
Once the project is built, you must copy the output assembly file to the computer that is running the Microsoft Dynamics NAV Development Environment. You locate and copy the control add-in assembly file (.dll), which is in the control add-in project output folder. By default, this is C:\Documents\MyDocuments\Visual Studio\Projects\[Your Addin Project]\[Your Class Library]\bin\Debug.
On the computer running the development environment, paste the assembly file in the Add-ins folder. By default, this is C:\Program Files (x86)\Microsoft Dynamics NAV\71\RoleTailored Client \Add-ins.
At this point, in more complicated scenarios, you will create a manifest file and any resource files that you need to display your control add-in, such as images or style sheets. But for this HelloWorld example, we will skip right to registering the control add-in in Microsoft Dynamics NAV.
To register a control add-in, you include it in the Control Add-ins page in the Microsoft Dynamics NAV client. Enter the name of the control add-in as stated in the Microsoft.Dynamics.Framework.UI.Extensibility.ControlAddInExport, which in this code example is HelloWorld.
Enter the public key token, which you can determine by running the Microsoft .NET Framework Strong Name tool (sn.exe) on the assembly.
Enter a descriptive text for your control add-in.Now only a few steps remain to include your HelloWorld control add-in on a page.
From the Microsoft Dynamics NAV Development Environment, open Object Designer.
Create a new page and add a field control that can hold the HelloWorld control add-in. Something very simple like this will do:
Open the Properties window for the field control, locate the ControlAddIn property and select the HelloWorld control add-in from the Client Add-in lookup window. Choose the OK button.
Save and compile the page. Remember the page ID for the next step.
Run the new page from a web browser with the following command:
You should now see something like this:
Now you probably want to try a more advanced example. Go to Help for Microsoft Dynamics NAV 2013 R2 and read through the documentation on extending Microsoft Dynamics NAV. For more information, see Walkthrough: Creating and Using a Client Control Add-in in the MSDN Library.
Best regards,
The Dynamics NAV team