UiPath While, Do While and For Each Loops

While Loop

This is another conditional activity that continues to run an activity as long as the condition inside the while activity is satisfied. In the image, as long as ”i is less 10, it will start process CCleaner.

For each

This is a looping activity that runs a specific set of tasks per item stored inside a variable. For example, if a variable contains 11 items, for each item the activity will loop 11 times and run all the activities inside it Body Sequence 11 times

In the image, the message box activity will run for as many items as present inside the DTinput object variable.

For each row

Much similar to “For each” and is used to run a specific set of sequences per row of a data table. This is extremely useful to perform activities that include tables especially Excel and CSV files. The example image shows a looping that activity that runs for each row present in DTinput2 data table.

It is important to note that, For each is used for items is variables such as object variables, whereas For each row is used for rows in a data table.

Break

Stops execution of a particular loop, usually used with a condition to perform specific actions. Hence, this can only be used inside a looping activity.

Continue

The logical opposite of Break and is used to continue the execution of a workflow.