This article is not up to date and it has been substitute with new up to date content.

Please look the new up to date content.

How to use the Loop Unit

by Laura Cigardi
4,399 views Published on Oct 24, 2011
Applies to: All versions
Table of contents

The Loop Unit

The loop unit is an operation unit designed to iterate over an array of objects. At each iteration the unit provides as output parameters both the current object and the current index. The loop unit must be the source of two distinct OK links: one is followed when the iteration is not finished, and must be marked with the 'next' link code; the other is followed when the iteration has reached its end, and must be marked with the 'end' link code. In the following example a loop unit is used to send a newsletter to every selected customer automatically. This is done by iterating over all the selected customers and sending an email (composed with the Script Unit) with the Mail Unit to each one. When the loop unit has iterated over all the customers, it follows the OK Link with the 'end' code.

The loop unit is configured to iterate over the list of selected customers' emails:

Every time the OK Link with the 'next' code is followed, the link provides as parameter a new element of the list (the next selected customer email):

Secondary Array

It is possible to add other arrays to the iteration, using the "Add secondary array" command on the Loop Unit. For each secondary array the loop unit requires an input parameter, i.e. the array of objects to iterate over, and provides an output parameter, i.e. the current element of the array. Note that the iteration is controlled by the mandatory input array, and therefore the length of iteration is not influenced by secondary arrays: if the current iteration index is greater than the size of the secondary array, a null value is provided in output.

As an example, suppose that we want to customize the body of the email adding the username of the customer. A secondary array containing the name of the current customer is needed in order to use it at every iteration.

Now it is possible to associate the new secondary array with the list of usernames, in order to compose a customized email.

With a transport link the username is transported to the Script Unit.

 

 
 

This article is not up to date and it has been substitute with new up to date content.

Please look the new up to date content.