What is an Iterator?
An iterator is an object that passes data structures sequentially. It returns the following element and determines if further elements follow.
Configuration of an Iterator
Use the iterator activity to iterate over a variable. It has two output ports: each and after.
The Iterator works like a ‘foreach’ loop in Javascript, it takes a list of data records (in Simplifier: collection, in programming array) as input and loops over each list item in the data list (in Simplifier: struct). In the Iterator’s output nodes ‘each’ and ‘after’, you can define what should happen in each iteration, and what should happen after the last iteration has been finished.
Port | Description |
each | For every iteration, the following process will be executed. |
after | After all the iterations ended, the following process will be executed. |
To configure the input mapping for the Iterator, you need to define over which list of data (collection) you want to loop over (this is the left/parameter side). Here, select any collection, for example, a global variable or items of a table/list.
For the right/variable side, create a new global variable. The datatype needs to be the same struct that is defined for the input collection. In our example, we loop over a collection of the datatype ‘Address_Col’ that is stored in a global variable. This collection contains addresses with the datatype ‘Address_Struct’. So, on the right side, we use a global variable of the same datatype, ‘Address_Struct’. In each iteration, the current struct is stored in this global variable, so you can use its data in the process that is defined for the ‘each’ output node.