Decision task definition object
A Decision task (identified by "type": "Decision"
) adds branching logic to a workflow.
Here is an example of a Decision task:
"Dispatch Event": {
"type": "Decision",
"choices": [
{
"condition": "$.type !== 'Private'",
"nextTask": "Public"
},
{
"condition": "$.value >= 20 && $.value < 30",
"nextTask": "Value In Twenties"
}
],
"defaultTask": "Record Event"
}
In this example, suppose the workflow is started with an input value of:
{
"type": "Private",
"value": 22
}
Then the system will transition to the "Value In Twenties" task, based on the "value" field.
A Choice Condition MUST be a JavaScript expression and may be evaluated to return a boolean value. Previous task output parameters are accessible with $
identifier. See also list of JavaScript expression functions.
A Decision task MUST NOT be an End task.
The Decision task has following additional fields:
Field |
Type |
Required |
Description |
---|---|---|---|
|
Array[JSON Object] |
Yes |
The array whose elements MUST be objects. Each element of the array MUST be a JSON object and is called a Choice Condition. A Choice Condition may be evaluated to return a boolean value. A Choice Condition at the top level, i.e. which is a member of the "decisions" array, MUST have a "nextTask" field, whose value MUST match a task name. The system iterates over the top-level Choice Conditions in array order and transitions to the task specified in the "nextTask" field on the first Choice Condition where the JavaScript expression condition is evaluated to true. |
|
String |
Yes |
The default task to run if none of the Choice Conditions match. |
Choice condition
A choice condition is a JavaScript expression and may be evaluated to return a boolean value. The result of the JavaScript expression needs to be true in order for the route to be taken.
Previous task output parameters are accessible with $
identifier.
The following variables can be referenced in the expression:
Variable |
Type |
Description |
---|---|---|
|
JSON Object |
All the workflow executed tasks, including their input and output. |
|
String |
The workflow ID. |
|
String |
The workflow definition ID. |
|
String |
The workflow definition version. |
|
Integer |
The unique sequence number of the workflow for the workflow definition. |
|
String |
The task ID. |
|
String |
The task name. |
|
JSON Object |
The workflow definition variables. See Variables for more details. |
See also list of JavaScript expression functions.