For each item
Runs downstream blocks once for every item in a collection.
@lainstack/flow/for-each-item · Flow
How to use it
Section titled “How to use it”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) anditem-number(a number that starts at 0). See guidereferences. - 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
Collectinput only if you need theresultscollection. Without it no results are gathered. - An empty source skips the item branch and goes straight to
donewith statussuccess. - The limit is 100,000 items. A larger source fails the step.
- With
errorPolicystop-after-in-progress, one failed item stops new items, lets running items finish, and fails this block.doneis not taken. Withcontinue-and-collect-errors, the run goes on todone,summary.statuscan bepartial, and failures go to theerrorscollection. - A list typed by hand must have items of one shape.
@lainstack/run/set-detailscannot run inside the item branch. - To compare two whole lists, use
@lainstack/flow/checklistin list mode, not a loop.
Settings
Section titled “Settings”| 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. |
Outputs
Section titled “Outputs”| 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 |