Skip to content

Step: Each

  • Key: each
  • Category: Workflow Control
  • Description: Iterate over an array and execute nested steps for every processed item.

Inputs

  • arrayVariable (select, required): Context key or dot-path containing the array to process, for example orders or searchResults.items.
  • maxItems (number, optional): Safety limit for the number of items to process. Leave empty to process the whole array.

Loop Context

During each iteration, nested steps can read these context values:

  • item: Current array item.
  • index: Zero-based iteration index.
  • _each: Object containing item, index, total, isFirst, and isLast.

The runtime restores any previous item, index, and _each values after the loop finishes.

Outputs

  • item (array): Items that were processed.
  • items (array): Alias of item.
  • results (array): Per-iteration records containing index, item, nested step outputs, and any iteration error.
  • errors (array): Errors captured while processing items.
  • successfulItems (number): Number of iterations completed without error.
  • failedItems (number): Number of failed iterations.
  • totalItems (number): Original source array length.
  • processedItems (number): Number of iterations actually processed.

Notes

  • The source value must be an array. If it is a JSON string, the runtime tries to parse it as an array.
  • If a nested step fails, the loop records the error and stops processing further items.
  • Use maxItems when a loop calls expensive steps such as LLMs, HTTP requests, or tool actions.

Example

Given orders in the flow context:

  1. Set arrayVariable to orders.
  2. Add nested steps that read { {item.customerName} } and { {index} }.
  3. Read the loop summary from the step output, for example orderLoop.results.

Built with VitePress