For Each activity
The For Each activity iterates through recurring elements of a variable, performing other activities during each iteration cycle.
About this task
When you drop a For Each activity onto an orchestration, Studio creates the following two variables:
- loopvalue_X - During run time, as the For Each activity loops through a set of recurring elements, the loopvalue_X variable contains the value of the current element.
- loopcounter_X - During run time, as the For Each activity loops through a set of recurring elements, the loopcounter_X variable contains the current count of the number of iteration cycles that have been processed by the For Each activity.
Where X is equal to the number of For Each activities that have been dropped on the orchestration. For example, when the first For Each activity is dropped on an orchestration, the variables called loopvalue_1 and loopcounter_1 are created.
To use a For Each activity complete the following steps:
Procedure
- Open the Activities tab and the Logic folder.
- Drag the For Each activity onto the orchestration.
- In the Variable Name field, select a variable containing the recurring element that you want to loop through in the For Each activity.
- In the Element Name field click [...] to browse for the recurring element that you want to loop through in the For Each activity. The Select Recurring Element window is displayed.
- Select a recurring element and click OK.
Results
An XPath expression that refers to the recurring element is displayed in the Element Name field. The Variable Name field is automatically populated with the loopvalue_X variable created for this For Each activity. You can edit the generated XPath expression in the Element Name field.
You can add other activities within the For Each loop. Use the Break Loop and Continue activities to control iterations of the For Each loop.