Loops are used when you need to repeat a set of the same nodes a specific number of times.
NOTE - task loops do not have the concept of a for loop or do while loop. For that type of functionality consider using a recursive routine. Instead, iterations of a loop happen, essentially, all at once.
Loops are comprised of two different nodes, Loop Head and Loop Tail
The Loop Head node controls how many times the loop is processed and what data is used with the XML and XSL parameters. The Loop Head is also referred to as Loop Begin in some documentation.
Set the XML document in the Data Source parameter, and the XSL in the Loop Path parameter.
Variable Name this optional parameter was used to identify a variable from the xml to be used in each loop iteration. It's common now to use the output of the loop head node (<%=@results['Loop Head']['value']%>) from the parameter list.
XML (Data Source)
<user> <id>han solo</id> <id>darth vader</id> <id>leia organa</id> </user>
XSL (Loop Path)
In this example the loop would process three times passing the value, han solo, darth vader, and then leia organa.
The Loop Tail controls where the end of the loop is, and when the loop is exited. The Loop tail is also referred to as Loop End in some documentation.
Connecting nodes in a loop is similar to normal connecting. Inside the loop (between the Loop Head and Loop Tail) nodes connect normally. The difference for a loop, is that you must also connect the Loop Head directly to the Loop Tail node. This connection tells the engine what nodes are between the Loop Head and Loop Tail and are then included in an individual loop instance.
Below is a very simple loop modeled after a batch update to person records. In this loop you can see that the Loop Head is connected directly to the Loop Tail, along with the two nodes that are part of the update process.
Example run using the hard coded values from above. The important thing to notice on this run is that after the tasks for the initial Loop Head and Loop Tail (lines three and four), there are individual Loop head Tasks and Triggers for each instance the loop is run. The tasks are differentiated by the index number of their execution (for example, the first is ).
The details for one of the Echo nodes is shown to see its output. The parameter for the Echo node is <%=@results['Loop Head']['value']%>