Share This Post

Business Central Control Add-In Object

The Business Central Control Add-In Object allows you to add custom functionality to Dynamics 365 Business Central. A control add-in is a custom control, or visual element, for revealing and modifying the data within an iframe or a page.

For example, a control add-in can show the content of a webpage, visualize data as a chart or on a map, or host a custom web application. The add-ins can interchange data with the MS D365 server on different data types and can respond to user interaction to raise events that run the additional AL code.

Business Central Control Add-In Object Properties

1. Control Add-in Properties

In the control add-in definition, you must set the Scripts property to include scripts in the control add-in. The scripts could be local files in the package or references to the external files utilizing the HTTP or the HTTPS protocol.

With the StartupScript property, you can call a special script that runs when the page you have implemented the control add-in on, is loaded. These settings initialize the control add-in. With the Imagesand StyleSheet properties, you can specify additional styling to the Business Central Control Add-In Object.

2. Sizing of the Control Add-in

Control add-ins can either have fixed dimensions or dynamically adapt to the available space on the screen. By controlling the sizing of an add-in, you can ensure that the add-in and the surrounding content on the page remain optimal on smaller display targets such as the phone or when users resize the browser.

The following properties are available for you to specify how the sizing of the control add-in should behave.

  • HorizontalShrink
  • HorizontalStretch
  • MinimumHeight
  • MinimumWidth
  • MaximumHeight
  • MaximumWidth
  • RequestedHeight
  • RequestedWidth
  • VerticalShrink
  • VerticalStretch

3. Control Add-in Considerations

Designing Business Central Control Add-In Object that provide the best possible experience can require some additional planning, design, and implementation. The following considerations will help you design add-ins that look and feel seamlessly integrated with Dynamics 365 Business Central.

  • Respond to touch events so that mobile users or those on devices supporting touch input can also use the add-in.
  • Design content that is responsive and is able to flow, resize, or reorganize naturally based on the available space.
  • Consider the accessibility needs of users, for example by implementing keyboard access and support for screen readers.
  • Use the Style guidelines to apply a choice of colors, typefaces, and font sizes that match that of Dynamics 365 Business Central.
  • Provide language translation and other localizations that match the current user language in Dynamics 365 Business Central.

4. Control Add-in Syntax Example

The following Business Central Control Add-In Object example syntax defines a chart that can show how customers are represented per country on a map.

// The controladdin type declares the new add-in.

controladdin CustomersPerCountryChart
{
// The Scripts property can reference both external and local scripts.
Scripts = ‘https://code.jquery.com/jquery-2.1.0.min.js’,
‘js/main.js’;

// The StartupScript is a special script that the webclient calls once the page is loaded.
StartupScript = ‘js/chart.js’;

// Images and StyleSheets can be referenced in a similar fashion.

// The layout properties define how control add-in are displayed on the page.
VerticalShrink = true;

// The procedure declarations specify what JavaScript methods could be called from AL.
// In JavaScript code, there should be a global function LoadData(data) {}
procedure LoadData(Data : JsonArray);

// The event declarations specify what callbacks could be raised from JavaScript by using the webclient API:
// Microsoft.Dynamics.NAV.InvokeExtensibilityMethod(‘CountryClicked’, [{country: ‘M}])
event CountryClicked(Country: JsonObject);
}

page 50100 CustomersMapPage
{
layout
{
area(Content)
{
// The control add-in can be placed on the page using usercontrol keyword.

usercontrol(ControlName; CustomersPerCountryChart)
{
// The control add-in events can be handled by defining a trigger with a corresponding name.

trigger CountryClicked(Country : JsonObject)
var Data : JsonArray;
begin

// The control add-in methods can be invoked via a reference to the usercontrol.

CurrPage.ControlName.LoadData(Data);
end;
}
}
}
}

The control add-in is implemented as a usercontrol on a page called CustomersMapPage. For more information on Microsoft Dynamics 365 Business Central Control Add-In Object, please contact us.

Share This Post

Leave a Reply

avatar
  Subscribe  
Notify of
Skip to toolbar