JavaScript: Run Code
Description
Execute JavaScript code to process data, use conditional logic, perform advanced calculations, and more.
JavaScript EngineThe code you enter is executed using Googleās V8 JavaScript engine.
Instructions
Inputs
| Name | Description |
|---|---|
| Code | Enter the JavaScript to run. Set the actionās Output field with 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 9 days ago
