Skip to main content

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

Foreach Activity Editor

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

ApproachForeach ActivityManual Loop Pattern
SetupBuilt-inRequires custom logic
ClarityClear intentRequires interpretation
MaintenanceEasierMore complex
Error HandlingPer-iterationManual implementation
Progress TrackingAutomaticManual 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": []
}
}
PropertyTypeDescription
dimensionQueryobject | nullCorresponds 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.
workflowobjectThe embedded sub-workflow definition (same structure as a top-level WorkflowDefinition). Must contain its own StartWorkflowActivity.