msgToJs()

This function is used to transfer data from Control to the JavaScript interface of the WebView EWO as response to the toCtrl() function.

Synopsis

msgToJs(mapping inputParams, anytype data)

Parameters

Parameter Description
inputParams Input Parameters for the JS function
data Data to be transferred to the function

Return value

-

Error

missing/incorrect arguments

Description

This function is used to transfer data from Control to the JavaScript interface of the WebView EWO and must be called from within the "messageReceived" event of the EWO. The function is used as response to the toCtrl() JavaScript function.

The input parameters of the "messageReceived" event must be directly passed to the inputParams of the function.

Example

Following example demonstrates how to use the msgToJs function to return the values for the requests "getAttributes" or "getShapes" that are sent from JavaScript using the toCtrl function.

JavaScript
...
let params = {
  command:"getAttributes"
};
oaJsApi.toCtrl(params,{
  success: function(data) {console.log(data);},
  error: function(data) { console.error(data);}
});
Control - WebView EWO messageReceived Event
messageReceived(mapping params)
{
  switch(params.params.command)
  {
    case "getAttributes":
      this.msgToJs(params, this.scriptables());
      break;
    case "getShapes":
      this.msgToJs(params, getShapes(myModuleName(),myPanelName(),""));
      break;
    }
}

Additional examples for the usage of the function msgToJs can be found within the demo panels of the JavaScript interface.

Assignment

WebView EWO

Availability

UI

See also

execJsFunction(), toCtrl()