Skip to main content

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​

InputTypeRequiredDefaultWhat it is
FileFileNoJavaScript file (.js) that defines or exports the function.
FunctionStringYesFunction name; use object.method for a method of an exported object.
ArgumentsListNoArguments, in order.
Timeout (seconds)NumberNo300Maximum run time.
Fail on errorBooleanNotrueFail the step when the function throws; when false the error is returned in error.
InterpreterStringNoNode.js program to use; node on the PATH when empty.
ScriptStringNoCode that defines the function, typed in the agent, instead of a file.

Outputs​

OutputTypeWhat it is
resultAnyValue returned by the function (numbers, text, lists and dictionaries).
outputStringText the function printed.
errorStringError thrown by the function when fail_on_error is false; empty on success.