JavaScript APIs for actions
The Script activity for actions is enhanced to support asynchronous requests to servers that are identified as application resources. The following JavaScript functions can be used in the Script activity. For an example of how these functions are used, explore the StartProcess action that is provided in the Workflow Services toolkit.
Function | Description |
---|---|
tw.system.waitForContinueFlow() | Call this function to indicate that the script makes an asynchronous call. It prevents the action from continuing to the next step in the flow when the end of the script is reached. |
tw.system.continueFlow() | When this function is called from an asynchronous callback, it indicates that the asynchronous call is complete and the action can continue to the next step in the flow. |
tw.system.performRequest(name, options, callback, errorcallback) | Makes an asynchronous call to a server. You must call
waitForContinueFlow before calling this function, and the
continueFlow function must be called by the callbacks. Important: If
continueFlow is not called, the action cannot continue to
completion.
The tw.system.performRequest function has the following parameters:
|
tw.system.log(tw.system.model.name, tw.system.model.step.name, logString) | Use the tw.system.log API to debug the server-side script by printing logs to
the browser console. Logs print to the browser console if you are on a playback server, or if the
BROWSER_LOG_LEVEL is set to 3 or higher in your production Application Engine. Keep the first two parameters as-is and enter your log string in the third parameter.
|
tw.system.model() | The action or nested action in which the current script is defined (or running). |
tw.system.jsonReplacer(key, value) |
A JSON.stringify replacer that is used for converting JavaScript objects into the JSON format that is required by an action. This must be used for an application data persistence action after retrieving data from the data store. Special handling is performed for lists, dates, and validationErrors.
|
tw.system.jsonReviver(key, value) |
A JSON.parse reviver that is used for converting the JSON string into JavaScript objects that are required by an action. This can be used for an application data persistence action after retrieving data from the data store. Special handling is performed for lists and dates.
|