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
| Parameter | Type | Required | Description |
|---|---|---|---|
arrayPath | array | No | Path to reference an array from previous nodes |
inputArray | array | No | Direct input array of items to process |
contextData | object | No | Additional context data passed with each item |
targetFlowId | string | No | ID 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
| Field | Type | Description |
|---|---|---|
data | array | Array of results from each iteration |
Each result object contains:
| Field | Type | Description |
|---|---|---|
success | boolean | Whether the iteration was successful |
output | object | Output data from the target flow |
error | string | Error 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 → EndData 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
- Batch Size: Process arrays in batches of 50-100 items
- Error Handling: Always check for failed iterations
- Context Data: Pass shared data via contextData
- Timeout: Set appropriate timeouts for target flows
- 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]
Related Functions
- SubFlow - Execute single subflow
- BulkInsertMData - Bulk operations alternative
- JavaScript - Custom array processing
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]