Skip to content

Branch, loop and reuse

This guide is for authors whose automations have outgrown a straight line. It shows when to use which block; each block’s reference page has every setting and trap.

Use Condition for a yes or no. Pick the Value type, the Value, a Comparison and what to Compare with. The run leaves on True or False.

  • The comparisons fit the type: text can contain or start with, numbers can be greater than, dates can be before or after, lists can contain an item.
  • Text comparisons ignore letter case by default.
  • One Condition tests one comparison. Chain them for more.
One question, two paths. This run's amount was small, so it skipped the approval.

Use Switch to pick a path from up to 8 exact values, such as a status or a country code. Set the Subject and the Cases; the first matching case wins. Always wire Otherwise, so an unexpected value is handled instead of ending the run quietly.

A block after a branch can only use values from blocks that ran on its path. A setting that maps a block from the other branch has no value, and Condition and Switch fail on missing values rather than guess. Map from blocks that every path passes through.

Use For each item to run the same blocks once for every item in a list, every row of a table or every file.

  1. Set Items to the list.
  2. Wire the blocks for one item to the Item exit. Inside, map the current item and its item number from the inputs list.
  3. Wire what should happen afterwards to the Done exit. It runs once, after every item.
  4. To gather each item’s result, connect the last block of the item branch back to the loop’s Collect input. The loop then outputs Results.
The Item branch runs once per item and hands its result back to Collect. Done runs once, after every item.

Items may run at the same time, so do not rely on one item finishing before the next starts.

If an item fails decides whether the loop stops after the items already running, or carries on and collects the errors. The loop outputs how many items succeeded and failed.

Items overlap and finish in any order. Done waits for the last one.

When several automations do the same steps, build those steps once as their own automation and call it.

  1. Create an automation with the Called by an automation trigger.
  2. On the trigger, declare the Inputs callers must give, and the Returns handed back, mapped from blocks that run after the trigger.
  3. Test it with sample inputs, then publish it. Only published automations can be called.
  1. In the calling automation, open the block library’s Automations group and add the automation you want to call. This adds a Run automation block with the called automation’s inputs and returns filled in.
  2. Map its Inputs.
  3. Wire both exits: Completed, where its returned values are typed, and Failed, where an error code says why.

Each call runs the called automation’s live published version and waits for it to finish, approvals included. The called run has its own page under Runs, linked from the caller’s run.

The caller waits while the called automation runs, then continues with the values it returned.
  • Calls cannot loop back, cannot nest more than 3 levels deep, and one run can make at most 100 calls.
  • If you change the called automation’s inputs or returns in a way that would break callers, their next call fails until they are updated. The Run automation block keeps a copy of the contract from when it was added; adding it again from the Automations group takes the current one.
  • A draft run of the caller starts the called automation’s published version with its writes held, so the called automation must be published.

Last updated: