แก้ไข

Asynchronous considerations

Communication between AL code on the Business Central server and a control add-in's JavaScript code in the browser is asynchronous. These calls don't provide a synchronous return value across that boundary.

Declare procedures in the AL controladdin object without a return value. Exchange results through procedure parameters and event parameters instead.

Send results from AL to JavaScript

To send a result from AL to JavaScript, declare a procedure in the controladdin object with parameters for the result. Implement the corresponding JavaScript function. Call the procedure from AL to pass the result to JavaScript.

The result is sent in a separate procedure call, not returned to the original JavaScript call.

Send results from JavaScript to AL

To send a result from JavaScript to AL, declare an event in the controladdin object with parameters for the result. In JavaScript, call Microsoft.Dynamics.NAV.InvokeExtensibilityMethod with the event name and an array of result arguments. Handle the event in the corresponding trigger on the page's usercontrol.

The optional successCallback for InvokeExtensibilityMethod reports completion of the invocation. It doesn't receive a result from AL. To send result data to JavaScript, use a separate control add-in procedure call.

Learn more about invoking AL triggers in InvokeExtensibilityMethod method.

Control add-in object
InvokeExtensibilityMethod method
GetImageResource method
GetEnvironment method
Control add-in performance best practices
OpenWindow method