The For Each Loop activity takes as an input an array (collection) of objects and repeats the set of activities within the loop for each object in the collection. For example, if the input collection has five objects, the loop iterates five times. If the collection is empty, the loop does not iterate. There is no upper limit to the number of objects in the collection. The For Each Loop activity always runs on the computer on which the workflow runs.

The For Each Loop activity is a composite activity with two containers for activities:

Icon



Design Time Prerequisites

Run Time Prerequisites

Properties

The For Each Loop activity uses the input properties listed in the following table.

Display Name Internal Name Type Required Description

Input Collection

InputCollection

Array/Object

N/A

A collection of objects to be passed, one at a time, to the activities within the For Each Loop activity. If the activity that resides in the input container produces an array of objects as its output property, Input Collection is automatically set to that property. To view the current value of this property, right-click the loop container, and then click Properties.

Current Item

CurrentItem

Object

N/A

An index into Input Collection that activities within the loop can use as an input property. For the first activity in the loop container, this property is set automatically.

Errors and Exceptions

The For Each Loop activity uses the custom tracking service supplied by Service Manager to log errors and exceptions when the activity runs. The activity generates errors or exceptions under the following conditions:

  • If any error occurs in the ForEachLoop activity and that is not with the child activities, the workflow terminates.

  • If any error occurs within the child activities, the workflow terminates unless ContinueOnError=true.

  • If any of the input properties are null. The activity does not iterate.

Each activity within the For Each Loop activity must write its own errors or exceptions to the custom tracking service. The For Each Loop activity does not do so itself.

Remarks

Example