Branching and Loops
Use IF/ELSE Conditions to send an automation down different paths depending on the record, and Repeating Group to run steps once for every record in a list. Evaluate Record Set answers "do all, any, or how many of these records match?" so a branch can act on the answer.
Prerequisites
- An automation with a configured trigger.
- For loops, a step that produces a list of records, usually Find Records.
Add IF / ELSE branches
Add the IF/ELSE Conditions step
Click + and choose IF/ELSE Conditions. Enter a Name such as "Route by permit type".
Choose what to evaluate
Set Condition source to Entity record to test a record's fields (then set Entity selection and Record Id, usually the trigger's Record ID), or to Prior node output to test the result of an earlier step and pick it in Prior node.
Build the first branch
Under Branch Conditions, the first branch is IF. Give it a label, then add its conditions and choose AND or OR for that branch. Every IF and ELSE IF branch needs at least one condition.
Add more branches
Click Add Branch for each ELSE IF path. Click Add ELSE Branch for a catch-all path that runs when no other branch matches. Only one ELSE branch is allowed.
Save and add steps to each branch
Click Save Changes. The canvas splits into one path per branch. Click + inside a path to add the steps for that branch. The paths join again after the IF/ELSE.
Branches are checked from top to bottom and only the first branch that matches runs. In run history, the branches that did not run, and their steps, show as Skipped.
When there is no ELSE branch
If no branch matches and there is no ELSE branch, none of the branch paths run. The panel shows this case as the None Branch ("When no condition is met"). Add an ELSE branch whenever "no match" needs its own steps, and check the result in run history while testing.
Repeat steps for each record
Find the records
Add a Find Records step with the conditions that pick the records, for example every Inspection linked to the permit.
Add a Repeating Group
Click + after it and choose Repeating Group. Enter a Name and optional Description.
Choose the list
In Input list, choose the records from the Find Records step. The canvas shows "Repeat for each in" with the list name.
Add the steps to repeat
Click Select Action inside the group and add the steps to run for each record. Inside these steps, use the current record from the group (for example, its Record ID in an Update Record).
Records are processed one at a time, in order. IF/ELSE Conditions and another Repeating Group cannot be placed inside a Repeating Group.
Check a list of records
Evaluate Record Set checks every record in a list found earlier and reports All match, Any match, and Match count to later steps.
| Setting | Description |
|---|---|
| Name | Label for this step |
| Record set | The list from an earlier step, such as Find Records |
| Record predicate | Conditions each record is checked against |
| When the record set is empty | Return false, Return true, or Fail the node |
Follow it with IF/ELSE Conditions using Condition source Prior node output and pick the evaluation in Prior node to branch on the answer.
Example
Close a Building Permit only when every linked review is complete.
| Step | Setting | Value |
|---|---|---|
| Trigger | When record is updated, entity Plan Review | Watching Fields: Review Status |
| Find Records | Entity Plan Review | Permit is any of the trigger's Permit field |
| Evaluate Record Set | Record set | the Find Records result |
| Record predicate | Review Status is Complete | |
| When the record set is empty | Return false | |
| IF/ELSE Conditions | Condition source | Prior node output, the evaluation step |
| IF branch | All match is true | |
| IF path: Update Record | Record Id | the trigger's Permit field |
| Field: Status | Static: Ready to Issue |
Common mistakes
- Leaving a branch without conditions. Every IF and ELSE IF branch needs at least one.
- Expecting more than one branch to run. Only the first matching branch runs; order the branches from most specific to least specific.
- Looping over a large Find Records result when a single Update Record or a condition would do.
- Forgetting When the record set is empty. Decide whether "no records" should count as a match.