younifyd
Menu

For Each

Iterate over an array and execute workflow steps for each item.

Use it in a workflow

  1. Add a step and choose the For Loop connector.
  2. Pick the For Each action (under workflow).
  3. Fill in the fields below, then reference the result from later steps as {{forEach.response.data}}.

Fields

arraySourcestringrequired

Reference to the array to iterate over (e.g., {{previousStep.response.data.items}} or {{trigger.products}}).

itemVariablestring

Variable name to hold the current item in each iteration (e.g., 'item', 'product').

Default "item"

indexVariablestring

Optional variable name to hold the current index (e.g., 'index', 'i').

Default "index"

totalCountSourcestring

Reference to the total record count, if known upfront (e.g., {{listProducts.response.meta.results.total}}). Enables 'X of Y processed' progress tracking for batch jobs. Leave blank if the total is unknowable ahead of time — processed-count progress still works without it.

recordIdentitystring

Expression identifying this record's stable business key (e.g. {{item.sku}}). Enables cross-run history, per-record filtering, and record-scoped rerun in batch jobs. Falls back to iteration index when unset.

isPrimaryProgressSourceboolean

Mark this loop's progress as the one that rolls up into the batch job's top-level 'X of Y' progress and record count. Defaults to false — with a single loop in the whole call graph (including any loops inside called workflows/routes) it's picked automatically, but with more than one, exactly one must be marked explicitly or the batch job will pick whichever happens to report first.

Default false

Examples

Iterate over order line items

Loop over each line item in the order, exposing it as {{item}} (and its position as {{index}}) to the nested steps

json
{
  "arraySource": "{{trigger.body.lineItems}}",
  "itemVariable": "item",
  "indexVariable": "index"
}

Need more? See the For Loop guide for connection setup and behaviour shared by every action.

Was this page helpful?