Foreach
The Foreach activity iterates over a collection of dimension members, executing a subprocess for each item independently.
Purpose
Use the Foreach activity to:
- Process multiple members in a loop
- Execute the same operations for each element in the collection
- Handle batch processing scenarios

Behavior
Iteration Model
- Subprocess-Based: Built on the Subprocess activity
- Independent Instances: Each iteration is treated as a separate subprocess instance
- Parallel Support: Iterations execute in parallel
- Collection Processing: Processes items from a dimension query
Structure
Foreach: [Collection]
└─ Subprocess Instance (for each item)
├─ Activity 1
├─ Activity 2
├─ ... ... ...
└─ Activity N
Usage Notes
- Each iteration has its own execution context
- The subprocess template is reused for each item
- Items are processed independently
- Progress tracking shows status of each iteration
Common Patterns
Multi-Entity Operations
Foreach: Account List
└─ Subprocess: Account Operations
├─ Validate Account
├─ Calculate Balance
└─ Generate Report
Comparison to Manual Loops
| Approach | Foreach Activity | Manual Loop Pattern |
|---|---|---|
| Setup | Built-in | Requires custom logic |
| Clarity | Clear intent | Requires interpretation |
| Maintenance | Easier | More complex |
| Error Handling | Per-iteration | Manual implementation |
| Progress Tracking | Automatic | Manual logging |
When to Use
- Processing multiple records or entities
- When iteration logic is straightforward
- When you want clear visualization of iteration status
- When each item requires the same processing steps
- For batch operations with independent items
JSON Reference
{
"discriminator": "ForeachWorkflowActivity",
"activityId": "<uuid>",
"name": "Foreach",
"positionX": 0,
"positionY": 0,
"advanceRule": 2,
"dimensionQuery": {
"dimension": "Entity",
"members": []
},
"workflow": {
"settings": {},
"activities": [
{
"discriminator": "StartWorkflowActivity",
"activityId": "<new-uuid>",
"name": "Start",
"positionX": 0,
"positionY": 0,
"advanceRule": 2,
"preventMultipleActiveRuns": true,
"dueDateCalculationMode": 0,
"parameters": []
}
],
"arrows": []
}
}
| Property | Type | Description |
|---|---|---|
dimensionQuery | object | null | Corresponds to the Collection field. A dimension query object defining which dimension members to iterate over. The current member is available as {burst} inside the subprocess. |
workflow | object | The embedded sub-workflow definition (same structure as a top-level WorkflowDefinition). Must contain its own StartWorkflowActivity. |