JavaScript: Run Code
Availability
This workflow action is available on our Business and Enterprise for Incident Management pricing plans. Please contact our Sales Team to upgrade to an account with this action.
Description
Execute JavaScript code to process data, use conditional logic, perform advanced calculations, and more.
JavaScript Engine
The code you enter is executed using Google’s V8 JavaScript engine.
Instructions
- If you have not done so already, please follow our instructions to Create an Incident Workflow.
- When you are prompted to add actions , select this action.
- Enter the following Inputs and then click Save. Continue following instructions to Publish the Workflow. When the action runs, you will see the Outputs listed below.
Inputs
Name | Description |
---|---|
Code | Enter the JavaScript to run. Set the action’s Output field with setOutput() . setOutput() must be called with a string value.Please read Action-Specific Field References for more information about how to retrieve a value from another workflow action. |
Outputs
Name | Description |
---|---|
Output | The string value passed to setOutput() in the JavaScript Code. |
Result | Value that shows if the action was successful or not. Either "Success" or "Failed." |
Result Summary | Brief description of what the action did or if it failed. |
Error | Brief description that is populated if the action failed. |
Action Limitations
- The maximum output size is 5MB.
- Output must be a string type.
- The execution time limit is 10 seconds.
- The memory limit is 512MB
- Code executes using UTC as the local timezone.
Examples
Reference Workflow Fields
Use Field References (e.g., workflow.id
) as part of your JavaScript code.
var workflowId = workflow.id;
setOutput("This Action is part of Workflow: " + workflowId);
Output a Stringified Object
Outputting a stringified object is helpful when constructing a JSON body for an HTTP request.
var requestBodyForHttpAction = {
incidentID: incident.id,
currentDateTime: new Date().toISOString()
};
setOutput(JSON.stringify(requestBodyForHttpAction));
Updated 3 months ago