Skip to content

Script Task

The Script Task element runs JavaScript code, and then the process continues. Use it to calculate or transform data, for example to build a full name from two fields or to sum the amounts in a list.

To add one, drag Script Task from the palette, or click Append script on the element before it. Its settings are on these tabs:

  • General: the ID and the Name shown on the canvas (default: “ScriptTask”).
  • Inputs: the data the script uses. See Inputs and data.
  • Script: the code.
  • Outputs: the value the script returns.
  • Multi Instance: shown only for a multi-instance element. See Repeat an element for each item.

Write the code in JavaScript Code. The code runs as the body of a function:

  • Each input of the element is a variable named by the input’s ID, for example parameter1.
  • Process values are also available, such as $id (process ID), $name (process name), $now (current time) and $businessKey.
  • Use return to return the result.

For example, with the inputs parameter1 (first name) and parameter2 (last name):

return parameter1 + ' ' + parameter2;

The editor suggests names as you type. You can also insert a value from Insert Variable.

The script runs on the Cellosign server. It can’t call external systems; use a Web Service for that. If the script is empty or fails, the process fails. The editor doesn’t check the code, so test it by starting a process.

The value that the script returns is the returnValue output. Later elements can use it as an input.