Creating complex branches using the variable evaluator

In some complex cases, just using exit codes for flow branching decisions might not be enough. You can also use the variable evaluator to do the branching decision.

About this task

Platform Process Manager supports complex user variable expressions in the variable evaluator. In the following example, if J1 sets var2’s value to 1, it will trigger J7.

Image illustrating a variable evaluator to create branches in a flow

The variable evaluator serves as an intermediate step between jobs and the validation of variable decision branches. Typically, the predecessors of a variable evaluator assign values to various user variables. When all the variables are set, the variable evaluator will evaluate all of its variable expression branches and determine which successors to start executing. If there is no predecessor to the variable evaluator, the variable evaluator will start and run to completion immediately.

When you specify the variable expressions for each branch, you can use a combination of variables, operators, and constants. The variable evaluator supports the following operators: <, >, =, >=, <=, !=

The basic variable expression consists of one variable, one operator, and one constant: variable operator constant. For example, #{A} > 1.

You can also create larger and more complect expressions by joining smaller expressions using the following boolean operators:

&& (AND), || (OR), ! (NOT), () (parentheses). However, you can only apply ! (NOT) to variable expressions and not to literals. That is, !({#A} > {#B}) is valid while !({#A}) >{#B} is not.

For example, the following at all valid combinations of variable expressions:

  • #{A} < 4 && #{B} > 3
  • !(#{A} < 4 || #{B} > 4)
  • !(#{A} > 2 && #{B} > 3) || #{C} > 5

You can also specify an else branch decision. The variable evaluator only evaluates else branches to TRUE if all other non-else branches evaluate to FALSE.

Procedure

  1. View the sample: Workload > Definitions > Flow Definitions > New > Flow Definition and select Importing an example definition, flowarray_eval.xml in the Create Draft Definition dialog.

    Explore the sample to learn how to pass variables from a parent flow to a subflow and from the subflow to the parent flow.

  2. To insert a variable evaluator in your flow diagram, in Flow Editor, from the menu select Insert > Variable Evaluator and click in your flow diagram.

    The variable evaluator is added to the flow diagram.

  3. Draw dependency lines by selecting the dependency icon, then drawing a line from the variable evaluator to work items.

    The predecessors will likely have variable definitions on which the variable evaluator will make decisions. If you do not define any dependencies for the variable evaluator, the variable evaluator will be triggered immediately when the flow runs.

  4. Select the selection icon, select a dependency arrows that indicate branches from your variable evaluator to other work items that follow it, right-click and select Open Definition.

    The Variable Evaluator Definition dialog is displayed.

  5. Draw the lines linking the variable evaluator to the decision branching jobs that depend on the variable evaluator.
    • Specify a variable expression

      The variable evaluator branches to this job if the variable expression that you specify is TRUE. Specify a variable expression or a combination of variable expressions.

      If you specify multiple branches that evaluate to TRUE in a workflow, they will all run their next jobs.

      Note:

      If, at runtime, a variable is undefined and thus cannot be resolved to a value, the variable evaluator evaluates the corresponding sub-expression to FALSE; however, the whole expression might not be evaluated to FALSE.

    • else

      The variable evaluator branches to this job if all the other variable expressions are FALSE.

      If you specified multiple else statements in a workflow, they will all run their next jobs if the all of the other (non-else) variable expressions are FALSE.

  6. Click OK.