Run JavaScript function
Call one function in a JavaScript file with Node.js (or Windows' built-in JScript when Node.js is not installed), passing JSON-compatible arguments, and return what it returns (promises are awaited with Node.js).
Command in the Scripts toolkit · id ooa.script/run_javascript_function · 7 inputs (1 required), 3 outputs
Inputs
| Input | Type | Required | Default | What it is |
|---|---|---|---|---|
| File | File | No | JavaScript file (.js) that defines or exports the function. | |
| Function | String | Yes | Function name; use object.method for a method of an exported object. | |
| Arguments | List | No | Arguments, in order. | |
| Timeout (seconds) | Number | No | 300 | Maximum run time. |
| Fail on error | Boolean | No | true | Fail the step when the function throws; when false the error is returned in error. |
| Interpreter | String | No | Node.js program to use; node on the PATH when empty. | |
| Script | String | No | Code that defines the function, typed in the agent, instead of a file. |
Outputs
| Output | Type | What it is |
|---|---|---|
| result | Any | Value returned by the function (numbers, text, lists and dictionaries). |
| output | String | Text the function printed. |
| error | String | Error thrown by the function when fail_on_error is false; empty on success. |