A brief post on logical expressions in SharePoint Designer Workflows with instruction on how to deal with their main limitation. Continue reading
SharePoint Designer workflows allow several conditions to be specified for a set of actions. Each condition results in a logical value (true/false) and can be ANDed or ORed with other logical conditions.
Here is an example set of 4 conditions. If they result in a logical true, the actions (not shown) are executed.
If Property1 equals Initiation: Init1
and Property2 equals Variable: Var1
or Property3 contains abc
and Property4 not equals xyz
The only logical operators are AND and OR. There is no NOT, but this can probably be handled within each conditional expression itself.
There are several conditional expressions: equals, not equals, is empty, begins with, matches regular expression, etc.
The main drawback is that there is no way to group the logical expressions. There is no way to put in parenthesis. So, if you want to do “x=1 or (x=2 and y=3)”, you have to do a workaround. But first, you need to know the priority of each condition.
The rule is that precendence is based on the left-to-right order of the expression. So, “x=1 or x=2 and y=3″ is equivalent to “(x=1 or x=2) and y=3″. The table below shows a couple of examples of how to rearrange your expression without grouping functionality. The letters A, B, C, and D represent a single logical condition (e.g., x=1).
|Desired Expression||Actual Expression|
|A or (B and C)||B and C or A|
|(A or B) and (C or D)||A and C or A and D or B and C or B and D|
Looking at our original example, the grouping is effectively:
If (((Property1 equals Initiation: Init1
and Property2 equals Variable: Var1)
or Property3 contains abc)
and Property4 not equals xyz)