How to: Set Up a Windows Client Control Add-in on a Page
After you have registered a Microsoft Dynamics NAV Windows client control add-in, you can use it on Microsoft Dynamics NAV Windows client pages. To use a control add-in on a page, you add it to a field control. Depending on the design of the control add-in, you may also need to follow these steps:
Bind the control add-in field to a data source.
Control add-ins can use data from a field in the table that is associated with the page or from a C/AL global variable.
Modify the OnControlAddin Trigger to process data that is sent from the Microsoft Dynamics NAV Windows client.
Add C/AL code to triggers that call methods and properties in the control add-in.
Preparing to Set Up the Control Add-in
To prepare for setting up the control add-in
If the control add-in uses data from a table that does not exist, then create the table.
For more information, see How to: Create a Table.
If the page to which you want to add the control add-in does not exist, then create the page. As appropriate, associate the page with the table that you created in step 1.
For more information, see How to: Create a Page.
Setting Up a Control Add-in on a Page Field
To set the ControlAddIn property on a field
Open the Microsoft Dynamics NAV Development Environment.
On the Tools menu, choose Object Designer, and then choose the Page button.
Select the page, and then choose the Design button.
In Page Designer, add a field control for the control add-in or use an existing field control.
Select the field, and then on the View menu, choose Properties.
In the ControlAddIn property value, choose the up arrow.
In the Client Add-in window, select the control add-in from the Client Add-in window, and then choose the OK button.
For more information, see the ControlAddin Property.
To bind the field to data in a table field or C/AL global variable, set the SourceExpr property.
Note If the SourceExpr property is set to a C/AL global variable, then in the C/AL code, add code to the OnAfterGetRecord trigger to populate the global variable. For more information, see OnAfterGetRecord Trigger.
Close the Properties window.
Modifying the Microsoft Dynamics NAV Windows Client Control Add-in Event Trigger
When invoked on a page, a control add-in can raise an event that sends data to Microsoft Dynamics NAV Server. In the C/AL code for the page, the event calls the OnControlAddIn trigger of the field control that is applied with the control add-in. To process the event data, you add C/AL code to the OnControlAddIn trigger. For more information, see Exposing Events and Calling Respective C/AL Triggers from a Windows Client Control Add-in.
To add C/AL code to the control add-in event trigger
On the View menu, choose C/AL Code.
In the C/AL Editor, locate the following field control trigger.
Fieldname - OnControlAddIn(Index : Integer;Data : Text)
Fieldnameis the name of the field control that is applied with the control add-in.
Note If the data type of the field's SourceExpr property is BigText, then the
Add the C/AL code to the trigger.
Close the C/AL Editor.
On the File menu, choose Save, select Compiled, and then choose the OK button.
Calling Control Add-in Methods and Properties From C/AL
Control add-ins can expose methods and properties that you can call using C/AL code from triggers on a page to extend the control add-in user interface. To complete this procedure, you must know the method or property names. For more information, see Exposing Methods and Properties in a Windows Client Control Add-in.
To call a control add-in method or property
In the C/AL Editor, locate the trigger from which you want to call the method or property.
Note You cannot call control add-in methods or properties from the OnInit, OnOpenPage, or OnNewRecord triggers.
Add the C/AL code to the trigger that calls the method or property.
To call a method, add the following code.
To call a property, add the fowlloing code.
ControlNameis the name of the field control that is applied with the control add-in. The name is specified by the Name Property.
MyPropertyare the names of the method and property of the control add-in to be invoked.
- To call a method, add the following code.
Save the page.
TasksHow to: Install a Windows Client Control Add-in Assembly
How to: Register a Windows Client Control Add-in
How to: Install a Windows Client Control Add-in Assembly
Walkthrough: Creating and Using a Windows Client Control Add-in
ConceptsWindows Client Control Add-in Overview
Installing and Configuring Windows Client Control Add-ins on Pages
Developing Windows Client Control Add-ins