ForEach-Loop Activity
- Last UpdatedJun 26, 2024
- 2 minute read
Activity Description
The ForEach-Loop activity is used to loop an activity through a collection within an XMLIterator Variable. It allows repeated execution of an activity or group of activities. It must always be used along with the Next Loop Activity.
Activity Properties
You can configure the ForEach-Loop activity by specifying appropriate values in the Activity Properties area. To access the Activity Properties, click the Activity Properties menu in the Tool Bar. Or, right-click the ForEach-Loop activity and select the Activity Properties option. The Activity properties are organized under groups of related properties. The properties under each group are described in this topic.
Name & Description
Specify the name and description for the activity in this group.
Name - Enter the name for the activity.
Property Type: Optional (This property needs to be set only if necessary.)
Description - Enter a brief description for the activity.
Property Type: Optional (This property needs to be set only if necessary.)
Configuration
The Configuration group has a single property for selection of the XMLIterator Variable to be looped through.
XMLIterator - Select the XML Iterator variable to be looped through. All XMLIterator variables as declared in Start activity are available for selection.
Property Type: Mandatory (This property must be set if the action is to be executed.)
Example of XMLIterator Variable in ForEach-Loop
In this example, the XMLIterator Variable is used to get approval from all managers in the Managers.XML file containing the list of all users who are managers.
Managers.XML file
<Managers>
<Users>
<User id=1>
<Name>John</name>
</User>
<User id=2>
<Name>Jim</name>
</User>
<User id=3>
<Name>Victor</name>
</User>
<User id=4>
<Name>Andy</name>
</User>
</Users>
</ Managers >
Step 1: XMLIterator Variable is defined for users. The node Users holds the collection of managers.

Step 2: The Decision activity is set within a ForEach-Loop activity.

Step 3: The XMLIterator Variable Users is defined in XMLIterator field of ForEach-Loop properties. The Execution type is set to Parallel as the decision is to be processed simultaneously.

Step 4: The XMLIterator Variable Users is specified in the condition for making a decision.
Output: When the above workflow is invoked, Quickflow Engine resolves "XMLVariables.user.users.ID".