Script Adapter widget

Draft comment:
This topic is shared by BAW, CP4BA. Last updated on 2025-03-13 12:15
The Script Adapter widget is used to insert logic between widgets during event communication. It transforms data that is published by one widget into a format understood by another widget. For example, you might use the Script Adapter widget to transform the data that is published by the Properties widget into a format that is understood by a custom widget on a Case Details page. You can also use the Script Adapter widget to insert logic between widget event communication. For example, you might use the Script Adapter to perform custom validation on data that is published by the Properties widget. Because you can configure the Script Adapter widget to display event data at runtime, you can also use the widget to help debug your solution.

When wiring widgets, if the widgets have the same event and the format for the event data is the same, you can simply wire one widget to another. However, if the format for the event data is not the same, you will need to transform the data in the source event into a format expected by the target widget. The Script Adapter widget is the way you achieve this transformation. When the Script Adapter widget receives an event from a widget it is wired to, it displays the event details in the Received Event section. The Script Adapter then runs a script that transforms the data as a function with a "payload" parameter, which is the payload of the incoming event. The script is how you manipulate the payload using any type of logic that you feel is necessary. The value that your custom code returns is the payload of the outbound event of this widget. The Sent Event section displays this information.

For example, a Script Adapter receives a wired event with a payload of "test data", which the Received Event section displays. The Script Adapter has the following script:
alert("The value of the payload is: " + payload);
return "Event Payload: " + payload + "!";

The Sent Event section displays "Event Payload: test data!" as the payload for the outbound event.

IBM® Business Automation Workflow pages that include this widget by default

The Script Adapter widget is included on the Cases page by default.