Execute js code

Description

Enables you to write and execute a JavaScript code. Variables created inside this activity can not be accessed outside. Variables created using 'Assign value to variable' can be used and modified inside this block.

Below is an example of setting up and using an action to extract a specific number from the string "Task No. 542388 - pending, expired" by a regular expression using the .split() method.

a=a.split(/\s#\s//); // ["Task", "542388 - pending, expired"]
a=a[1].split(/\s-\s/)[0]; // "542388"

Parameters

Statement

Contains a JavaScript code to be executed. For example:

function calc(a, b) {
return a + b - a*b;
}
//Variables num1, num2 are local - created inside the block
var num1 = 10;
var num2 = 15;
//Variables result, arr are global and
//created outside using 'Assign value to variable'
result = calc(num1, num2);
arr.push(result);
arr[4] = 18;

If an error occurs during the execution of this activity then the global variables used in this block will not be updated after finishing the execution.

Comment

Contains an annotation to the activity.

Usage Examples

This activity is useful for complicated functions with many variables involved: parsing, combining data, etc.