Loopfour
Blocks

Loop Block

Iterate over collections to process each item in a workflow

The Loop block iterates over a collection (array) and executes its contained blocks once for each item. Use it to process line items, batch records, or iterate over API results.

Configuration

OptionTypeDescription
collectionexpressionThe array to iterate over (e.g., {{steps.fetch.output.items}})
itemVariablestringName for the current item (default: item)
indexVariablestringName for the current index (default: index)
breakConditionconditionStop When in the panel. Optional. Stops the loop early once the condition is true. Checked after each item; when items run concurrently, after each batch, so set batchSize too or it is checked only once, after all items
batchSizenumberBatch Size in the panel. Optional. Processes the collection in groups of this many items (1 to 1000)
maxIterationsnumberSafety limit to prevent infinite loops (default: 100)

How It Works

  1. The Loop block receives an array from an upstream block
  2. For each item in the array, it executes all blocks connected inside the loop
  3. Each iteration has access to the current item and index
  4. After all iterations complete, downstream blocks receive the collected results

Example Patterns

Process Invoice Line Items

Salesforce (get line items) -> Loop (for each line item)
    -> Stripe (create invoice item)
    -> End Loop -> Stripe (finalize invoice)

Batch Customer Notifications

QuickBooks (list overdue invoices) -> Loop (for each invoice)
    -> Slack (send reminder to customer channel)

Multi-Record Sync

HubSpot (list updated deals) -> Loop (for each deal)
    -> Transform (map to QB format) -> QuickBooks (update record)

Best Practices

  • Set maxIterations appropriately. For known-size collections, set it to the expected max. This prevents runaway execution.
  • Keep loop bodies lightweight. Heavy operations inside loops multiply execution time. Consider using Parallel blocks for independent iterations.
  • Handle empty collections. If the input array is empty, the loop body never executes. Downstream blocks receive an empty results array.

Frequently Asked Questions

If the input array is empty, the loop body is never executed. Downstream blocks receive an empty results array. The workflow continues normally.

Yes. You can place a Loop block inside another Loop block to handle nested data structures. Each loop has its own item and index variables.

The default maxIterations is 100. You can increase this in the block configuration, but be mindful of execution time and API rate limits. For very large collections, consider batching with multiple workflow runs.

Yes. Set Stop When (breakCondition) on the Loop block. The loop checks it after each item and stops once it is true; the items already processed keep their results. To skip individual items without stopping, use a Condition block inside the loop instead.

On this page