Administration Guide

Building Conditional Statements

By default, all workflow operations within Actions, Triggers, and Functions are unconditional, and Alloy Navigator executes them in the order as they appear in the list. To make workflow more flexible, Alloy Navigator supports IF-THEN-ELSE conditional statements. For example, you can use a conditional statement to create a Trigger that will generate alert notifications when a poor satisfaction rating is reported, or congratulation messages when the satisfaction rating is high.

INFO: For details on customer satisfaction survey, see How to Create and Maintain Customer Satisfaction Survey.

Each conditional statement establishes a rule where the included operations run only if that rule is satisfied. This rule is called criteria. If the conditional criteria is not satisfied, all operations within the IF section will be skipped. Adding ELSE and ELSE IF sections gives you the ability to specify alternative operations. You can specify criteria with one or multiple conditions joined with logical operators into logical expressions.

INFO: For details on building criteria, see Building Criteria.

Here is the structure of a basic conditional statement:

IF (<Criteria>)
	<workflow operation>

If <Criteria> is true, then <workflow operation> is executed. If <Criteria> is false, nothing happens.

Using ELSE IF and ELSE statements, you can create more complex conditional statements, as follows:

IF (<Criteria 1>)
	<Group of workflow operations 1>
ELSE IF (<Criteria 2>)
	<Group of workflow operations 2>
ELSE IF (<Criteria 3>)
	<Group of workflow operations 3>
ELSE IF (<Criteria 4>)
	<Group of workflow operations 4>
	<Group of workflow operations 5>

When an IF-THEN-ELSE statement is encountered, the workflow engine evaluates its criteria. If the <Criteria 1> is TRUE, the workflow operations from the 1st group are executed. If the <Criteria 1> is FALSE, each ELSE IF statement is evaluated in order. When an ELSE IF condition is evaluated to TRUE, the workflow operations immediately following the associated ELSE IF are executed. If no ELSE IF condition evaluates to TRUE, or if there are no ELSE IF statements, the operations following ELSE are executed. After executing the statements following ELSE IF, or ELSE, execution continues with the operation following the closing END IF.

See an example of a conditional statement with two criteria and an ELSE statement:

Conditional statements can be nested inside other conditional statements and combined with unconditional operations, which enables you to build flexible workflow with complex hierarchical conditions. Here is an example of a nested IF statement:

IF (<Criteria 1>)
	<Group of workflow operations 1>
		IF (<Criteria 1.1>)
			<Group of workflow operations 1.1>
			<Group of workflow operations 1.2>
	<Group of workflow operations 2>

To add a conditional statement to a Function, Action, or Trigger:

  1. If you already defined an operation which you want to execute on condition, click it.

  2. 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.

  3. To add an ELSE IF group, select the IF line or another ELSE IF line (if already exists) and click New > “ELSE IF” Group. Repeat this step as many times as needed.

  4. If you want to specify an alternative workflow for situations when neither condition evaluates to True, select the last line before END IF and click New > "ELSE" Group. The ELSE row appears before the END IF row.

  5. Specify a condition for IF and ELSE IF groups:

    1. Double-click the IF (<Double click to add criteria>) or ELSE IF (<Double click to add criteria>) row. The Criteria dialog box opens.

    2. Specify your condition. For details on building conditions, see Building Criteria.

      IMPORTANT: For a Custom SQL Criterion condition, the 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.

    3. Repeat these steps for other ELSE IF groups (if any).

  6. Add conditional workflow operations:

    1. Select the IF ([Criteria]) or ELSE IF ([Criteria]) row and add operations that will run when the condition evaluates to TRUE. Repeat this step for other ELSE IF groups (if any).

    2. If the ELSE group exists, select the ELSE row and add the alternative workflow operations that will run when the condition evaluates to FALSE.

      INFO: For details on adding workflow operations, see Adding Operations.

    3. Click OK to save the conditional statement.

      NOTE: You may want to add comments to your conditional workflow operations to indicate what those operations do. For instructions, see Adding Comments.

If you want to modify a conditional statement, double-click it, make your changes using the Criteria dialog box, and save it.

When the operation list contains many conditional groups, you can collapse a group by clicking the collapse icon next to its conditional statement, as illustrated below. To expand a collapsed group, click the expand icon. To expand or collapse all groups, click Expand All or Collapse All at the top of operations.

You can copy, delete, or move conditional statements up or down using the Copy / Paste commands available in the pop-up menu and the Delete, Move Up, and Move Down buttons.

NOTE: When you copy or delete conditional statements, workflow operations specified for those statements stay unchanged. To copy or delete workflow operations, do it one by one.