If Task

Last updated on
14 March 2018

The If task provides logical branching based on the status of the last executed task preceding the IF, or based on the value of a variable. The IF task provides a TRUE and a FALSE branch and is the mechanism used control the workflow path by the maestro engine.

Configuring the If Task:

In the Template Builder, add a new task of type If Task to your workflow. Once it's added, click on the Edit menu icon on the top left corner of the task. 

The task is used to check a condition which is either a Variable or the Last Task Status.

If you choose By Variable, you will need to select the variable to test and the operation. You can use the 4 main operators (=, <, >, !=) to test against a value. The = and != will work with strings while all four operators work for float or integer values.

If you choose By Task Status, there are 4 task states that can be set by the Maestro Engine. Typically, most asks return a SUCCESS or CANCEL status.

//Maestro queue status codes for task execution status
const TASK_STATUS_ACTIVE = 0;
const TASK_STATUS_SUCCESS = 1;
const TASK_STATUS_CANCEL = 2;
const TASK_STATUS_HOLD = 3;
const TASK_STATUS_ABORTED = 4;

Your own custom interactive and batch function tasks can use any of these statuses.
An example of the code using the maestro API: 

MaestroEngine::setTaskStatus($queueID, TASK_STATUS_CANCEL);

Once you have set the IF Task conditions, you will need to draw the True / False branch lines so the workflow engine will know which task to execute next upon a True or False condition result from the IF Task. Use the Edit Task icon on the IF task and you will see the options to draw the two different lines. The False line is drawn in red.

The IF task is used to generally cause a logical loop-back condition - ie: you need to route the task back to a user to edit the form or content. We refer to this as looping back. Normally the workflow engine will never execute a task a second time except under this condition.

There is no limitation on the number of times your workflow may loop-back or the number of IF tasks and loops in a workflow.

For more information on how the Maestro engine handles loop-backs and regeneration of workflow processes to track each and every instance of the workflow history, refer to this blog article: http://www.nextide.ca/maestro-d8-loopback-and-regen

Help improve this page

Page status: No known problems

You can: