JustPaid Workflows
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)
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

On this page