For Each

flow · C211 · starter-package 7.0.1

Run a saved child workflow sequentially for up to 256 list items with explicit item and index input names.

Behavior

Select a saved Body Workflow with an exact revision and portable preset inputs. Connect Items, then provide the child workflow's Item Input and Index Input names. The names must be distinct, start with a letter, use only letters, numbers, underscores, or hyphens, and contain at most 64 characters.

For Each asks Nodestly to run the selected saved workflow for the active owner. It executes at most 256 child runs sequentially, injects the current item and zero-based index, and preserves the parent cancellation and deadline. Add-on code never evaluates text as code.

The current item can be a live file, browser page or other workflow item. Connect the corresponding Workflow Input to a consuming block inside the child. To pass a newly created item back, connect it to a named Workflow Output. Its ID in Results remains usable by the caller for the rest of that run, subject to the item's expiry or explicit deletion.

After completion, Item and Index identify the last item visited, Count gives the number visited, and Completed fires. Results contains the output record from each child in input order. In the child, connect the computed value to Workflow Output and give it a name. For example, if the child doubles the items [3, 0, 5] and names its output total, Results is [{"total":6},{"total":0},{"total":10}].

An empty list returns Item = null, Index = -1, Count = 0, and Results = []. A child with no declared output contributes an empty record. Continue contributes its returned record and advances. Break counts the item that triggered it and ends the loop before adding that child's record to Results. A failed or cancelled child stops the loop before it emits Results.

Settings

IDSettingControlDefaultRules
targetBody Workflowsaved-workflowNot setSaved workflow
itemInputItem Inputtextitem1–64
indexInputIndex Inputtextindex1–64

Choose the saved Body Workflow in block settings so Nodestly can prepare its dependencies before the run. Match the two names to Workflow Input blocks in the child. Wire a record to targetInputs for additional named values that stay the same across iterations. Each iteration supplies its own item and index. A connected input takes precedence over its matching setting. Existing workflows with a connected Body Workflow can determine the child's identity at runtime.

Common uses

Search for this block with: foreach, loop, iterate.

Errors and limits

Missing workflows, outdated saved versions, unsupported inputs, duplicate input names, more than 256 items, too much data, cancellation, time limits, errors in the selected workflow, and invalid results stop the workflow with a clear message. Check the selected workflow and its named inputs. If both are correct, update the Starter package and Nodestly, restart Nodestly, and run the workflow again. If the same correctly configured Body Workflow still returns an invalid result, report the highlighted For Each block as a product defect. Failures produce no Item, Index, Count, or Completed output.

Connector data types

The type below is the data type that actually travels through the connection. Any additional validation is described separately in this block guide.

DirectionConnectorTypeRequired
Inputtarget — Body Workflowrecordyes
InputtargetInputs — Additional Child Inputsrecordno
Inputitems — Itemslistyes
InputitemInput — Item Inputtextyes
InputindexInput — Index Inputtextyes
Outputitem — Itemanyon success
Outputindex — Indexnumberon success
Outputcount — Countnumberon success
Outputresults — Resultsliston success