Iterators

   

 

Iterator actions work by executing their child actions for each item that the iterator finds.

 

For example, a list iterator might have 3 items: "A, B, and C", and a variable to set : "ListItem".

 

When the iterator runs, it will run its child actions 3 times - the first time, the variable "ListItem" will have value "A". The second time, it will have value "B" and the last time, value "C".

 

 

iteratoroverview

 

(The list iterator in the above screenshot has been paused during the fifth of six iterations.)

 

 

Iterator Actions Summary

 

Action Name

Summary

File Iterator

Iterate through multiple files or a FileSet.

List Iterator

Iterate the elements of a list.

Folder Iterator

Iterate through multiple folders.

File Contents Iterator

Iterate the lines of a text file.

INI File Iterator

Iterate the sections or entries of an INI file.

WMI Process Iterator

Iterate running processes on a Windows computer.

XML Node Iterator

Iterate XML nodes matching an XPath.

ADO Dataset Iterator

Iterate for each row in a dataset returned from a SQL query.

CSV Field Iterator

Iterate through each row of a CSV or other character-delimited file.

Web Service Iterator

Iterate through an array of values returned from a Web Service.

 

Visual Studio.NET Solution Iterator

Iterate through each project in a Visual Studio.NET Solution file.

There is also the While Loop action which, while not technically an iterator, can execute its children more than once.

 

Iterator Script Events

 

Iterators have the following script events:

 

Before Action & After Action (common to all actions)

 

These events fire before and after each iteration (including the last iteration.) It is not really recommended that you use these events for Iterator actions.

 

OnAfterEachIteration

 

This event fires after all the child actions have run for each iteration. In the example above, OnAfterEachIteration would execute following each invocation of the "Do something else" action group.

 

This is equivalent to having a Run Script Action as the last child of the iterator.

 

Note: The best way to run some script before each iteration begins is to add a Run Script Action as the first child of the iterator.

 

 

OnFirstRun

 

This script event fires the first time the action is run, before the variable has been set to its first value. If the iterator relies on some variables to generate the list of iterated values, you can set them from the OnFirstRun event.

 

This is equivalent to having a Run Script action placed immediately before the iterator action.