Skip to content

Iteration

Nilesh Ghodekar edited this page Aug 23, 2017 · 3 revisions

Overview

The Iteration feature is similar to a ForEach loop construct allowing the activity to iterate over a collection of values and take action on or utilise each of those elements in the collection one at a time in the group of value expressions defined for the activity.

Iteration

The instance value can be referenced in the group of value expressions defined for the activity using the [//Value/...] lookups.

To break out of the iteration loop when continuing the iteration till end is not required or not desirable, set the special variable $__BREAK_ITERATION__ to true (or 1).

Prior to build v2.16.0710.0, during each iteration only the expressions using [//Value/...] lookups were re-evaluated for updated values. As of build v2.16.0710.0, the expressions using [//WorkflowData/..] lookups are also re-evaluated for updated values in each iteration. This implementation now allows a WorkflowData value stored in a one iteration to be accessible for further evaluation and manipulation in the next iteration. e.g. using this enhancement, it is now possible to "traversing a reference hierarchy" to reach a level meeting a specified criteria and then terminate the iteration in these activities using Iteration capability.

As of build v2.17.0721.0, Query definitions can contain [//Value] lookups i.e. the current iteration value can be used to define a Query. However this support is currently only enabled for Send Email Notification activity. This support will be expanded to remaining activities in future releases.

Supported Activities

Implementation Guidance

While the Iteration feature is conceptually similar to a ForEach loop, it is not expected to be used to loop over more than a handful of times even though there is no hard-coded upper limit on the maximum number of iterations.

As of build v2.16.0130.0, WAL supports defining a collection of queries in the Query Resources configuration of the supporting activities. Depending on the use case, it may be elegant and more performant to use a query collection than the iteration feature.

Examples

Iterating over Members being added to a group

Using an Update Resources activity for the Iteration Collection, specify [//Delta/ExplicitMember/Added] to get the resources which are being added in the current request.

Then for each [//Value] in the collection, determine if it is a User and not a Group or other resource type. If it is a User, then added it to the WorkflowData value to be used by other child activities.

Activity Display Name Get Users being added to the Group
Iteration [//Delta/ExplicitMember/Added]
Value Expression Target Allow Null
IIF(Eq([//Value/ObjectType], "Person"),InsertValues([//Value]),Null()) [//WorkflowData/UsersAdded]

Workflow for changing e-mail address / managing ProxyAddresses attribute

See the TechNet wiki titled MIM2016 MIMWAL: Create workflow for changing e-mail address by Daniel Malmgren on managing ProxyAddresses attribute when the email address of the user changes.

Clone this wiki locally