Looping over lists and line items

Zapier · Advanced · 10 min

Orders, invoices and forms often contain lists; without a loop you can only act on the list as a whole.

One trigger can carry a whole list. An order holds several products; a form answer holds several tags. Zapier calls such lists line items. A normal action receives the whole list at once (often joined with commas). When you need one action per item, such as one CRM product line per ordered product, use a loop.

A loop means "repeat these steps for each item". Looping by Zapier creates loops from:

  • Text: split a value such as red, green, blue by a separator (a comma by default).
  • Line items: one iteration per item in a list field. You can include several line-item fields together, such as product name and quantity.
  • Numbers: a start and end value, for example 1 to 10.

Every step after the Looping step runs once per item. Things to know:

  • Iterations run in parallel, not one after another, and each appears as its own run in Zap history.
  • Steps after the loop use one task per iteration, so a 200-item loop with two steps uses 400 tasks. Put one-time steps before the loop.
  • To run a step only once at the end, add a filter that passes only when the loop_iteration_is_last field is true.
  • One Looping step per Zap, no loops inside loops, and a cap on iterations (500 by default).
  • A test creates only the first iteration; a live run creates all of them.

Formatter's line-item tools help prepare lists before looping, for example turning text into line items.

Remember

  • Looping runs later steps once per item in a list
  • Iterations run in parallel and each uses tasks
  • Use loop_iteration_is_last with a filter for a one-time final step

Watch out for

  • Mapping the preview loop values field, which exists in tests but not in live runs.

Check yourself

  1. An order has 5 products and 2 steps come after the Looping step. Roughly how many tasks do those steps use?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: help.zapier.com/hc/en-us/articles/8496106701453