Loopfour
WorkflowsSteps

Repeat for each item or run steps side by side

Process each invoice in a list one at a time, or run independent steps at the same time, using the loop and parallel steps in a workflow.

Use a loop when the same steps should happen for each item in a list, such as each overdue invoice. Use a parallel step when several separate jobs can happen at the same time, such as updating your ledger and your CRM.

Before you start

Have an earlier step that returns the list to process. For parallel work, choose jobs that do not need each other's results.

Repeat for each item

  1. StepFind overdue invoices
    A list of invoices comes back.
  2. StepLoop: for each invoice
    The steps inside run once per invoice.
  3. OutputReminder sent
    One email per invoice in the list.

Add the Loop block

Drag Loop from Core Blocks onto the canvas. It appears as a box.

Choose what to repeat over

Choose the box. Leave Loop Type on For Each — iterate over a collection. Under Collection, point at the list from an earlier step, such as the invoices found. See Use results from earlier steps.

Put the steps inside

Drag the steps that should happen for each item into the box, where it says "Drop blocks here to add steps". Inside the box, a step can use the current item, such as this invoice's customer and amount.

Join what comes after

Join the box to the step that should run once every item is done.

Good to know about loops

  • Items are worked through one at a time, in list order.
  • If a step fails for one item, the loop stops there by default. Open the run under Runs to see the failed step.
  • Stop When ends the loop early once a check is true, such as when a running total passes a limit.
  • Batch Size works through the list in groups of that many items.
  • A loop runs its steps once per item, unless it stops early or an item fails. The editor also lists For — repeat N times and While — repeat until condition is false, with Iterations, While Condition and Max Iterations, but these are not used when the workflow runs. Use For Each.

Do several things at once

  1. TriggerDeal closes
  2. StepParallel
    Two branches start together.
  3. StepCreate the customer in QuickBooks
    Branch one.
  4. StepPost to #finance in Slack
    Branch two.
  5. OutputBoth done
    The branches join before the workflow continues.

Add the Parallel block

Drag Parallel from Core Blocks onto the canvas. It appears as a box.

Add the branches

Drop the steps for each separate job into the box, where it says "Drop blocks here to add branches". Each branch runs on its own.

Choose what happens if a branch fails

Under Strategy, choose Wait All — wait for every branch or Fail Fast — stop on first error.

Use parallel only for jobs that do not depend on each other. If one step needs another's result, such as the new customer's ID, put them one after the other instead.

Check it worked

Test with a short list. Under Runs, check which items were processed and what each branch produced. A reminder inside an invoice loop sends once per invoice, not once per customer.

If something goes wrong

If the loop does no work, check the list it receives. If an item or branch fails, read the step error before retrying: earlier writes may have completed. See Fix and retry a failed run.

On this page