Monetize360
WorkflowsFunctionsSystem Functions

Loop Through Items

Repeat the same actions for each item in a list

Loop Through Items

Process each item in a list one by one. For example, if you have a list of customers, you can send an email to each customer automatically. This saves you from repeating the same steps manually.

Technical Name: ForEachFunction

Properties

  • Execution Mode: SYNC
  • Type: NATIVE
  • Category: System Functions
  • Function ID: 7d9e6750-c2a9-4c4d-8f7b-c42e96c1d8b3

Input Schema

Parameters

ParameterTypeRequiredDescription
arrayPatharrayNoPath to reference an array from previous nodes
inputArrayarrayNoDirect input array of items to process
contextDataobjectNoAdditional context data passed with each item
targetFlowIdstringNoID of the target flow that processes each item

Note: Either arrayPath or inputArray must be provided.

[Image placeholder: ForEach configuration panel]

Input Example

Using Direct Array

{
  "inputArray": [
    {"orderId": "ORD-001", "amount": 150},
    {"orderId": "ORD-002", "amount": 200},
    {"orderId": "ORD-003", "amount": 175}
  ],
  "contextData": {
    "userId": "user-123",
    "processDate": "2024-01-15"
  },
  "targetFlowId": "process-order-flow-id"
}

Using Array Path

{
  "arrayPath": "${fetchOrders.output.data}",
  "contextData": {
    "batchId": "${start.output.batchId}"
  },
  "targetFlowId": "process-order-flow-id"
}

Output Schema

FieldTypeDescription
dataarrayArray of results from each iteration

Each result object contains:

FieldTypeDescription
successbooleanWhether the iteration was successful
outputobjectOutput data from the target flow
errorstringError message if the iteration failed

[Image placeholder: ForEach output visualization]

Use Cases

Batch Processing Orders

Process multiple orders in parallel:

Start → FetchPendingOrders → ForEach(ProcessOrder) → SendSummary → End

Data Transformation

Transform each item in a dataset:

{
  "inputArray": "${loadData.output.records}",
  "contextData": {
    "transformationType": "normalize"
  },
  "targetFlowId": "transform-record-flow-id"
}

[Image placeholder: ForEach workflow pattern]

Performance Considerations

Parallel Execution

ForEach executes iterations in parallel by default:

  • Faster processing for independent items
  • Configurable concurrency limit
  • Automatic load balancing

[Image placeholder: Parallel execution diagram]

Best Practices

  1. Batch Size: Process arrays in batches of 50-100 items
  2. Error Handling: Always check for failed iterations
  3. Context Data: Pass shared data via contextData
  4. Timeout: Set appropriate timeouts for target flows
  5. Logging: Implement logging in target flows for debugging

Workflow Example

Start → FetchCustomers → ForEach(ProcessCustomer) → AggregateResults → End

Target Flow (ProcessCustomer):
  Start → ValidateData → InsertMData → EmailNotification → End

[Image placeholder: Complete ForEach workflow example]

Limitations

  • Maximum array size: 10,000 items
  • Maximum parallel executions: 100
  • Timeout per iteration: 5 minutes
  • Total timeout: 30 minutes

[Image placeholder: ForEach limitations diagram]