The JavaScript Actor is an important and useful built-in Actor type that can be used to simplify a flow by writing JavaScript business logic or validation code in the script input parameter.
To improve the usability of an Actor and an entire flow, we recommend writing only short sections of JavaScript code even though an Actor can include any number of JavaScript rows.
The javascript.flow and javascript-advanced.flow examples show various ways to use a JavaScript Actor in a flow.
Click Actions > Examples in the Main menu to open the examples.
The Actor's description includes the detailed explanation of the Actor's capabilities. Click > Description in the right corner of the Actor.
a > b ? a : b
self.agg += value
To summarize the values of an array, use the self keyword to access the Actor's state. The state is maintained between the executions of the same Actor in the flow. For example, when the SumArray Actor is invoked in an Iteration in the flow, its JavaScript code is executed across all the Actor's executions.
To access iteration data, use the contextLoop object's methods contextLoop.index(), contextLoop.stop() or contextLoop.skip().
For example, if you need to stop the iteration when a condition is true:
if ( xxx ) {
contextLoop.stop();
}
print(flowArgs.v3); //read the value of argument v3 - Access by name
flowArgs["v3"] = "Hello"; //write into the argument v3
for (var i in flowArgs) { // Enumerate all arguments
print(flowArgs[i]); //read the value
flowArgs[i] = null; //remove the value
flowArgs[i] = "abc"; //write the value
}
flowArgs; // Expose all flow args as Actor result
rows.forEach(row => {...})
var sum = 0;
for each (var i in input) {
sum += Math.abs(i);
}
sum;
print("The value of Const1 is: " + Const1.value);
throw "Invalid Data Received"
SumArray.result == ForEach.result && ForEach.result == 21
where the SumArray and ForEach Actors precede the current Actor in the flow.
The JavaScript Actor is an important and useful built-in Actor type that can be used to simplify a flow by writing JavaScript business logic or validation code in the script input parameter.
To improve the usability of an Actor and an entire flow, we recommend writing only short sections of JavaScript code even though an Actor can include any number of JavaScript rows.
The javascript.flow and javascript-advanced.flow examples show various ways to use a JavaScript Actor in a flow.
Click Actions > Examples in the Main menu to open the examples.
The Actor's description includes the detailed explanation of the Actor's capabilities. Click > Description in the right corner of the Actor.
a > b ? a : b
self.agg += value
To summarize the values of an array, use the self keyword to access the Actor's state. The state is maintained between the executions of the same Actor in the flow. For example, when the SumArray Actor is invoked in an Iteration in the flow, its JavaScript code is executed across all the Actor's executions.
To access iteration data, use the contextLoop object's methods contextLoop.index(), contextLoop.stop() or contextLoop.skip().
For example, if you need to stop the iteration when a condition is true:
if ( xxx ) {
contextLoop.stop();
}
print(flowArgs.v3); //read the value of argument v3 - Access by name
flowArgs["v3"] = "Hello"; //write into the argument v3
for (var i in flowArgs) { // Enumerate all arguments
print(flowArgs[i]); //read the value
flowArgs[i] = null; //remove the value
flowArgs[i] = "abc"; //write the value
}
flowArgs; // Expose all flow args as Actor result
rows.forEach(row => {...})
var sum = 0;
for each (var i in input) {
sum += Math.abs(i);
}
sum;
print("The value of Const1 is: " + Const1.value);
throw "Invalid Data Received"
SumArray.result == ForEach.result && ForEach.result == 21
where the SumArray and ForEach Actors precede the current Actor in the flow.