Script Adapter

Script Adapter allows you to map event data from one format into another between two widgets.

The Script Adapter widget is wired between two other widgets so that it can perform a data transformation on the event payload. Using this widget, you can:

The logic is implemented with Javascript code and the returned value of the code is the outgoing event payload.

Use the following procedure to create Javascript code for a received event.

  1. Click Configure from the script adapter widget menu.
  2. Type in the Javascript code that you want to use to map the event. You should end the script with a Return statement.
  3. Check one or both of the following:
    • Show Script Text to display a read-only view of the script.
    • Block Outbound Event to prevent the mapped event from being sent. This is useful for using this widget as an event viewer, rather than an adapter.
  4. Click OK to save the settings.

When the Script Adapter widget receives an event from a widget it is wired to, it will display the event details in the Received Event section and then run the script. The script is run as a function with a "payload" parameter which is the payload of the incoming event. You can manipulate the payload and add any type of logic that you wish. You should end your code with a return statement. The value that is returned from your custom code will be the payload of the outbound event of this widget (provided it has not been blocked). The Sent Event section displays this information.