Step Variables

Step Variables are flowObject level variables defined while designing the workflow. These variables are only accesible inside the flowObject and are not propogated through out the process.

Step variables can be defined for a flow Object, in Input/Output tab of the property panel. A step variable can be a String, List or Map.

The step variables for a flow-object can be used inside the flow-object to create dynamically evaluated expressions. All the defined step variables are pushed into msg json object. So, these variables need to accessed via msg. prefix with the variable name. Any variable which needs to be dynamically evaluated can be written as a javascript expression inside string template - ${ }.

Note: The values/keys inside List and Map object are not evaluated.

Example 1

Take a workflow with a script Task, and define the following step variables :

   input1 : "Ouput1"  - String
   input2 : "${23+34+(72*60)}"  - String (JS Expression)
   input3 : [1,2,3,4] - List
   input4 : {'a' : 'b', 'c':'d'} - Map

Once you define these step variables inside your script task with msg. prefix, you can access them in your script, for examples:

    if (msg.input1 === 'Output1') {
        var evalInput2 = msg.input2;
        msg.input4['a'] = msg.input3[2];
    }

Example 2

Suppose in a workflow, you want to modify and use a value, which is an output of some other flowObject(eg. ServiceTask or Business Rule Task), you cannot modify the value unless it is a script task. So, whenever there is a need for modification of some variable, a script task is necessary. With the introduction of step variables, you can directly modify or evaluate the variables obviating the need for explicit script task.