If you're new to rule builders then don't start here, make sure you check out the 'Using the Donesafe Rule Builder (Beginner)' article first. Otherwise let's begin.
By now you should understand the basics of AND and OR rules. Once you get the hang of those they're pretty straight forward. BUT what if you want to build a more complex set of rules by combining AND and OR rules in the same rule set? To do that, you'll need to use Rule Groups.
What are rule groups?
With Donesafe's rule builder, you can create rule 'groups' to allow you to mix and match AND/OR rules with as much complexity as you need. As an example, you can set rules up to say rules like:
If the (Workflow Step = Draft) AND (the Location = Sydney OR San Francisco)
If the (Workflow Step = Draft, Under Review OR Complete) AND (the Type = Health, Safety, OR Environmental)
If the (Workflow Step = Incident Recorded AND the Type = Safety) OR (Workflow Step = Actions & Review Complete AND (the Type = Health OR Environmental)) OR (Escalate for Urgent Attention = True)
For most standard accounts, this level of complexity is more than they'll need, BUT, for the automators out there this rule builder is a life saver.
In order to demonstrate this we'll go ahead and create two rule sets using rule groups. The first will be a simple grouping.
Simple Rule Groups.
To demonstrate a simple Rule group, let's say you'd like to make an automation for incidents that fires when the workflow step is equal to 'Incident Recorded' AND the location is equal to "Pyrmont Office" OR "Melbourne Office".
(example conducted on an incident automation)
Firstly, you need to think of the default set of rules, without any groups added as a group unto themselves. So we'll call the main group, the 'Parent Group' and any groups within it 'Sub Groups'.
Set your first rule as [Workflow Step] [Equal] [Incident Recorded]
2. Rather than adding another rule, Click [+Add Group] and set the Parent Group AND/OR to 'AND'.
This states that the first rule must be true AND whatever we put into the sub group below must also be true. You can see that the 'sub group' has a second 'AND/OR' option for within that sub group, as well as additional [Add Rule] and [Add Group] options for adding rules and even more groups to that sub group.
3. Within the sub group add two rules:
[Location] [Equal] [Pyrmont Office] (or a location you have)
[Location] [Equal] [Melbourne Office] (or a location you have)
4. Set the subgroup AND/OR setting to 'OR'.
Your rules should now look like this:
And you're done. This rule will now fire when the workflow step is equal to 'Incident Recorded' AND the location is equal to Pyrmont Office or Melbourne Office.
Now let's a make an advanced grouping.
Advanced Rule Groups
I'm going to throw you in the deep end here and we're going to make an advanced rule group to demonstrate some of the additional uses and properties of rule groups.
Again, remember to think of your main rule set as a 'Parent Group' unto itself under which we'll be adding 'Subgroups'.
To demonstrate this, I'm going to build the rule:
If the (Workflow Step = Incident Recorded AND the Type = Safety) OR (Workflow Step = Actions & Review Complete AND (the Type = Health OR Environmental)) OR (Escalate for Urgent Attention = True AND A person involved exists = True)
I'll be referring the colours used above to help you understand the process as it unfolds
Start by deleting the default first rule so that there are no rules or groupings in your rule builder.
You're going this because you want to set up an OR set of rules between three different sub groups, so you need to start by adding groups rather than rules.
2. Add three Subgroups below your parent group by clicking the [+Add Group] Button three times.
3. Set your Parent AND/OR option to OR
Your rule set should now look like this:
To break this down, your parent group now has no standalone rules in it, only three sub groups. These three sub groups in order are your Blue, Green and Purple groups listed at the beginning of this example. Notice that the Green grouping listed at the beginning also has an Orange sub-subgroup within it, but we'll add that later.
4. Add your first two subgroup rules and set the AND/OR selector to AND. (this is for the blue group)
[Workflow Step] [equal] [Incident Recorded]
[Parent of Type] [Contains] [Safety]
Your Blue group should now look like this:
5. Add a rule to your second group (Green group)
[Workflow Step] [Equal] [Actions & Review Complete]
6. Click the 'Add Group' button next to your second subgroup (Green) to add a new sub-subgroup (Adding the Orange Group within the Green Group). Then set the Greensubgroup AND/OR to 'And'.
Your second subgroup rule set should now look like this:
7. Add two rules to your sub-subgroup (Orange).
[Parent of Type] [Equal] [Health]
[Parent of Type] [Equal] [Health]
8. Set the AND/OR builder of your sub-subgroup (Orange) to 'OR'
Your rule second (Green) subgroup should now look like this:
Here you're stating that in order for the second subgroup to be true, the workflow step must be 'Actions and review completed' AND the Type must be either Health OR Environment.
9. Add Two Rules to your third Subgroup (Blue) and set it's AND/OR to 'AND'
[Escalate for Urgent Attention] [Equal] [True]
[A person involved exists] [Equal] [True]
You've now set up an OR rule across three Sub-Groups of rules, one of which has another Sub-Group within it. This means that if ANY of the three subgroups requirements are met, that this rule set will return a 'true' result. If you've followed correctly, your rule should now look like this:
And here's the rule set:
If Either (Workflow Step = Incident Recorded AND the Type = Safety) OR (Workflow Step = Actions & Review Complete AND (the Type = Health OR Environmental)) OR (Escalate for Urgent Attention = True AND A person involved exists = True) then the requirements of this rule set have been met.
The good news is, if you understood that, then you can use the rule builder to a degree of complexity greater than 99% of any use cases you may run into.
Congratulations! You're now a pro.