Donesafe uses an incredibly malleable Rule Builder for everything from User Collections to Automations. Depending on the context of where this rule builder shows up, your intent for it as well as the available options may change, however the interface and process for building rules remains the same.

Being that as it is, the rule builder gets it's own article to assist you with getting the most out of it, wherever it may appear.

But first:

What are Rule builders used for?

Rule builders are used as gates for behaviour. So in essence; If 'x' rules are met, do 'y'. The 'y' is dependent on the context of where you see the rule builder. For example:

  • In workflows, the 'y' is: allow a user to advance the workflow.
  • In User Collections the 'y' is: include the user in the User Collection.
  • In Automations the 'y' is: trigger the event.

The 'x' here are the rules you define in the Rule builder. First we're going to create a basic AND rule (because those are the most common), and then we'll discuss the difference between AND and OR rules.

Building a basic 'AND' rule.

AND rules are some of the easiest and most common rules to build. They effectively mean, if ALL of the following criteria are met, then do 'y'.

The best way to illustrate this is to use an example.
 As an example, 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".

(again, the available rules change contextually on what you're doing, so if you want to follow along go to Settings > Automations > [Incidents] tab and click +Add)

The rule to trigger that automation would be built this way:

  1. Set your first rule
  • In the first field set "Workflow Step"
  • In the second field set "Equal"
  • In the third field set "Incident Recorded" (or a workflow step you have)You should now have this.

Now to add your second rule. 

2. Click the [+ Add Rule] button
You'll see another blank rule appear below your first

  • In the available field select "Location". The remaining two fields will appear
  • In the second field set "Equal"
  • In the third field set "Pyrmont Office" (or a location you have)

3. Ensure that 'AND' is selected as your rule mode by clicking AND at the top of the rule group

The colour of the selected AND/OR will go darker. By selecting 'And' you're saying that BOTH of these rules need to be met in order to continue.

Your Rule group will now look like this:

And you're done. This rule states that 'The workflow step needs to be equal to Incident Recorded' AND the 'Location needs to be equal to Pyrmont Office' in order to trigger the automation.

And that's it for AND rules. If you want to add more rules, just continue clicking the 'Add Rule' button as you go. Generally speaking, the more rules you add, the more specific a situation needs to be before the requirements are met.

Building a basic OR rule

OR rule sets are common also. An OR rule effectively means, that EITHER this criteria is met OR this criteria is met.

Again, using an incident automation as an example, I'm going to make an an automation rule that fires when the main incident type is recorded as EITHER Safety, Health OR Environmental. If you have different types of incident types, then use those instead.

(again, the available rules change contextually on what you're doing, so if you want to follow along go to Settings > Automations > [Incidents] tab and click +Add)

The rule to trigger that automation would be built this way:

  1. Set your First RuleIn the first field set "Parent of Type" (this means the type, or any types below it)In the second field set "Contains"In the third field set "Safety"
  2. Click the [+ Add Rule] button to add another rule
    You'll see another blank rule appear below your first
  • In the available field select "Parent of Type". The remaining two fields will appear.
  • In the second field set "Contains"
  • In the third field set "Health"

3. Click the [+ Add Rule] button again to add the third rule
You'll see another blank rule appear below your first

  • In the available field select "Parent of Type". The remaining two fields will appear.
  • In the second field set "Contains"
  • In the third field set "Environmental"

4. IMPORTANT: Ensure that 'OR' is selected as your rule mode by clicking 'OR' at the top of the rule group

Your Rule Group will now look like this:

And you're done. This rule states that the incident Type needs to be equal to Safety OR Health OR Environment in order for this automation to fire.

This illustrates the importance of understanding the difference between AND and OR rules. In the above case we've stated that either one of these options need to be met, and since it's not possible for all three to be met at the same time because they all look at the same field, selecting AND would have meant that this rule would be impossible to fire since a single field can't be three things at once.

And that's it for OR rules. You can add more options in the OR rule set by continuing to click the [+Add Rule] button. They also don't have to be for the same type of criteria, you could also state that if any of those a true or the location was 'Sydney' then fire the rule and that will work also.

Want to get more advanced?

If you'd like to learn how to combine AND and OR rules by using groups, make sure you check out the 'Using Groups in the Donesafe Rule Builder (Advanced)' article.

If you're a tinkerer it's also worth checking out the Automation & Workflow 'Things' section of the knowledge base for one off tips and tricks with the workflow and automations engine.

Did this answer your question?