Building conditional statements
By default, all workflow operations within Actions, Triggers, and Functions are unconditional, and Alloy Navigator executes them sequentially. To make your workflow more dynamic and flexible, Alloy Navigator supports conditional logic in your workflow operations and allows you to build IF...ELSE IF...ELSE...END IF conditional statements.
NOTE: For details on configuring operations within Actions, Triggers, and Functions, see Adding workflow operations.
The basic structure of IF...ELSE IF...ELSE...END IF statements is the following:
IF (<Criteria1>)
<Group of workflow operations #1>
ELSE IF (<Criteria2>)
<Group of workflow operations #2>
...
ELSE
<Group of workflow operations #3>
END IF
Using ELSE IF and ELSE statements is optional. You can build a condition without these blocks:
IF (<Criteria>)
<Group of workflow operations #1>
END IF
When processing conditional statements, Alloy Navigator calculates a Boolean value of the criteria. If the criteria return TRUE, Alloy Navigator executes the corresponding group of operations. If the first criteria return FALSE, Alloy Navigator checks the next criteria (if any), and so on. If all the criteria return FALSE, Alloy Navigator executes operations under the ELSE block. Then the execution returns to the point after END IF. If there is no ELSE block, then the execution just jumps to the point after END IF. Click here to view the example of a conditional statement.
In this simple IF...ELSE IF...ELSE...END IF statement, the Incident's Priority is set to 'High' when the Requester is 'Alyssa Royal', to 'Medium' when the Requester is 'David Berger', and to 'Low' for all other Requesters.
Your conditional statements can be nested into other conditional statements and combined with unconditional operations, which allows you to build flexible workflow that depends on complex hierarchical conditions. Click here to view the example of nested conditional statements.
IF (<Criteria1>)
<Group of workflow operations #1>
IF (<Criteria1.1>)
<Group of workflow operations #1.1>
ELSE
<Group of workflow operations #1.2>
END IF
ELSE
<Group of workflow operations #2a>
IF (<Criteria1.2>)
<Group of workflow operations #2.1>
END IF
<Group of workflow operations #2b>
END IF
To build a conditional statement:
-
To add a conditional statement:
-
If other operations or statements already exist, click the location where you want to add your statement.
-
Under Operations, click New > "IF" Group. Two rows appear: IF (<Double click to add criteria>) and END IF. The END IF row indicates the end of your IF group.
-
To add an ELSE IF group, select the IF line and click New > “ELSE IF” Group. Repeat this step as many times as needed.
-
If you want to specify the alternative workflow that will run when all the criteria are not satisfied, select the last line before END IF and click New > "ELSE" Group. The ELSE row appears before the END IF row.
-
Specify criteria for IF and ELSE IF groups:
-
Double-click the IF (<Double click to add criteria>) or ELSE IF (<Double click to add criteria>) row. The Criteria window opens.
-
Build the criteria that return a TRUE or FALSE value. For details, see Building criteria.
IMPORTANT: If you use a Custom SQL Criterion condition, your SQL expression must refer to objects that exist in the database by the runtime of your Action or Trigger. You cannot refer to objects being created by a Create Object operation at runtime.
-
Repeat these steps for other ELSE IF groups (if any).
-
Add conditional workflow operations:
-
Select the IF ([Criteria]) or ELSE IF ([Criteria]) row and add operations that will run when the criteria evaluate to TRUE. Repeat this step for other ELSE IF groups (if any).
-
If the ELSE group exists, select the ELSE row and add the alternative workflow operations that will run when the criteria evaluate to FALSE.
NOTE: For details on adding workflow operations, see Specifying workflow operations.
-
Click OK to save the statement.
-
To modify a conditional statement:
-
To modify the criteria, double-click the IF ([Criteria]) or ELSE IF ([Criteria]) row, make your changes using the Criteria window, and click OK. For details, see Building criteria.
-
To add an ELSE group to the statement, select the last operation in the IF group and click New > "ELSE" Group. Then add the alternative operations as needed. For details, see Specifying workflow operations.
-
To change the execution order of operations or to move a workflow operation between your IF and ELSE groups, select the operation and use the Move Up or Move Down buttons.
-
To remove an ELSE IF or ELSE statement, select the ELSE IF or ELSE row and click Delete. This will move corresponding operations up to the closest ELSE IF or IF group.
IMPORTANT: Removing the ELSE statement does not delete the operations specified within this statement. If you want to remove the operations, delete each operation individually.
-
To move a conditional statement in the list of operations:
-
To move a conditional statement up or down in the list of operations or in the hierarchy of other statements, select its row and use the Move Up or Move Down buttons.
NOTE: When you move conditional statements, you move only the statements but not the workflow operations specified for those statements. If you want to move the operations, move each operation individually.
-
To copy a conditional statement:
-
Right-click the statement to copy and choose Copy from the pop-up menu.
-
Right-click the location to paste the statement and choose Paste from the pop-up menu.
NOTE: When you copy conditional statements, you copy only the statements but not the workflow operations specified for those statements. If you want to copy the operations, copy each operation individually.
-
To remove a conditional statement:
-
Select the IF ([Criteria]) row of the statement to remove and click Delete. This removes the statement and "moves" all conditional operations up in the hierarchy of other statements and operations.
IMPORTANT: Removing conditional statements does not delete the operations specified for those statements. If you want to remove the operations, delete each operation individually.
TIP: Use the plus icon (+) to expand and the minus icon (-) to collapse a node in the statement. To expand or collapse all nodes, click Expand All or Collapse All.
Related Information:
Building criteria
Building conditions
Adding comments