Looping is a common method that allows the developer to iterate through a section to validate, perform, or complete an action against a collection of items. Pega Robot Studio™ provides two components for looping: ForLoop and ListLoop. You can find them in the Advanced section of the Toolbox.
The ForLoop component enables iterative execution of logic within an automation. It contains the same elements as the ForLoop structure in programming language that allows you to execute a logic a specific number of times or until a condition is true. If the break event node triggers, or when you reach the iteration limit, the iteration ceases.
The design block contains the main methods and events for the ForLoop. The ForLoop component allows for either dynamically setting or hard-coding the Initial, Increment, and Limit parameters for the loop. Optionally, you can set the component's properties from the Properties grid.
In the following example, data from a column in an HTML table populates a list box on a Windows form.
The ListLoop component allows you to read individual items of a list and execute events for each item. The component not only loops through a count of items (like the Connectable Loop) but also reads the contents of the list and outputs each item.
In the following example, the automation reads a list of items. When the value of an item matches Pega, the ListLoop execution halts through the Break method.