While Activity
Purpose: Execute an activity while a given condition evaluates to true. This activity provides looping functionality in workflows.
Input Properties
Condition
The Boolean condition to evaluate before each iteration. The loop continues while this condition is true.
Type: bool
Default: false
Required: Yes
Note: The condition is evaluated before each iteration. Can be a literal boolean, expression, or variable reference.
Output Properties
This activity has no output properties.
Port Properties
Body
The activity to execute on every iteration while the condition is true.
Type: IActivity
Note: Connect the activity or sequence of activities you want to execute in each loop iteration.
Usage Example
Scenario: Process items while a counter is less than 10
Configuration:
- Condition: "{{ Variables.Counter < 10 }}"
- Body: Connect to a sequence that:
1. Processes an item
2. Increments the Counter variable
Result:
- The Body activity executes repeatedly while Counter < 10
- Loop stops when Counter reaches 10 or condition becomes false
- Each iteration processes one item
Important Notes
- The condition is evaluated before each iteration, not just once
- If the condition is false initially, the Body activity never executes
- Use the Break activity inside the loop body to exit the loop early
- Be careful with infinite loops - ensure the condition will eventually become false
- For iterating over collections, consider ForEach activity instead
- The loop completes when the condition evaluates to false or a Break activity is encountered
Related Activities
- ForEach - Iterate over a collection of items
- For - Iterate over a sequence of numbers
- Break - Exit a loop early
- SetVariable - Modify variables used in the loop condition