In Presence, Rules allow you to specify the conditions which must be met in order for the item in question to execute. The standard Rules dialog box looks like this:
Rules are comprised of Conditions (e.g. A = B) and Condition Groups (e.g. A = B AND C = D).
Condition Groups can be nested. This means that you can combine groups of conditions to provide sophisticated boolean logic. To create a new nested group use the "+ And Group" or "+ Or Group" buttons. To change a condition group from AND to OR, or vice versa, use the "Switch Group" button. To remove a group use the "Remove" button.
To add a new condition, drag and drop an item from the left hand pane into the main (conditions) panel. This will bring up the conditions dialog (see below). The left hand pane lists all of the items available for comparison. If the item you wish to compare is not listed, drag another item and change it in the condition dialog:
Condition Dialog Options
Two values are (usually) displayed which will be compared against each other at runtime. You can edit these values as you wish. Values can be compared in the following ways:
- Equal to - returns true if both values are equal after runtime evaluation.
- Greater than - returns true if the result of the first (top) value is numerically greater than the result of the second (bottom) value.
- Greater than or equal to - As above, but will also return true if the values are equal.
- Less than - returns true if the result of the first (top) value is numerically less than the result of the second (bottom) value.
- Less than or equal to - As above, but will also return true if the values are equal.
- Between - Returns true if the first value is numerically greater than the second value and less than the third.
- Between (inclusive) - As above but will also return true if the values are equal.
- Like - This replicates the LIKE clause in an SQL statement. The "%" character represents any characters - for example Gr% will match Graham, Grim or Gruel (etc).
- Matches Pattern - Compares the values using Regular expressions syntax.
- Null (Unknown) - Only the first value is considered, and it will return true if the value is NULL, blank or unknown.
To reverse the logic (e.g. return TRUE if the first value is NOT equal to the second value) select "Is not.." instead of "Is..".
Notes on Nest Conditions
If only one condition is present the entire rule will either be TRUE or FALSE depending on the result of that condition. If two conditions are present the Rule will return TRUE if both conditions return TRUE (if the top group is an AND group) or if either condition returns TRUE (if the top group is an OR group).
As mentioned above conditions can be nested in AND / OR groups. Consider the following:
Logic dictates that this Rule can only evaluate to true under one of the following circumstances:
- NAME is 'Suzie', AGE is 63, EYECOLOR is 'Blue'
- NAME is 'Suzie', AGE is 63, EYECOLOR is 'Green'
Anything else will cause the Rule to evaluate to false, and the action that it is associated with will not take place.
Rules on Task Elements
Certain Task Elements allow you to specify a Rule. If the Rule does not evaluate the Task Element will not run. These include (at the time of writing):
To apply Rules to these Task Elements, right-click on the node and select "Rules > Set Rules". An icon will be overlayed on the Node showing an "R" symbol to identify the fact that Rules have been set. To clear Rules right click on the node and select "Rules > Clear Rules".
Rules are also used in the XML Query Node, XML Writer Node, the Create Graph Node, and elsewhere.