Skip to content

For each item

Runs downstream blocks once for every item in a collection.

@lainstack/flow/for-each-item · Flow

Use this block to run the same blocks once for each item of a list, a table, a collection or a set of files. Wire the blocks for one item to the item port. The done port runs once, after every item has finished.

  • Inside the item branch, two contextual sources exist: current-item (typed like one list element, one table row or one file) and item-number (a number that starts at 0). See guide references.
  • Items keep source order, but they may run at the same time. Do not rely on one item finishing before the next starts.
  • Connect the last block of the item branch to the Collect input only if you need the results collection. Without it no results are gathered.
  • An empty source skips the item branch and goes straight to done with status success.
  • The limit is 100,000 items. A larger source fails the step.
  • With errorPolicy stop-after-in-progress, one failed item stops new items, lets running items finish, and fails this block. done is not taken. With continue-and-collect-errors, the run goes on to done, summary.status can be partial, and failures go to the errors collection.
  • A list typed by hand must have items of one shape. @lainstack/run/set-details cannot run inside the item branch.
  • To compare two whole lists, use @lainstack/flow/checklist in list mode, not a loop.
Setting Key Type Details
Items (required) items Value Choose a List, File, Files, Collection, or Table source in its original order.
If an item fails errorPolicy One of Stop after in-progress items, Continue and collect errors Choose whether to stop after in-progress items or collect bounded errors. Default stop-after-in-progress.
Output Path Type
Total summary.total Number
Succeeded summary.succeeded Number
Failed summary.failed Number
Status summary.status Text
Results results Value
Errors errors Value
Exit Port Notes
Item item
Done done