While Loop

Use the While Loop activity to create a loop that runs based on the conditions you configure. A While Loop is one of the two types of loops available in Automation. This type of loop will continue running as long as its control condition is true. If you want to iterate through a list of objects in a table, see the For Each Loop Help topic.

Note:
  • You can stop a loop using the Break activity. For more information, see the Break Help topic.

  • You can skip the rest of a single iteration of a loop or continue after a failure using the Continue activity.

Loop Control

A While Loop activity runs for as long as the control condition is true. This control condition functions the same way as a Condition Block in that its control condition is a logical statement. You can either:

  • Set this condition to something that will always be true and use a Break activity to stop the loop.
  • Use a loop control variable. When you use a loop control variable, you change the value of the variable when you want the loop to end.

Note: If you forget to stop a While Loop, it will keep running for quite a while before automatically stopping. If you are iterating through a list of items, it is usually better to use a For Each Loop.

Using a Loop Control Variable

Use the following steps to create a loop variable that you can change to stop the loop:

  1. Create a local variable using the Boolean data type and set its value to true.
  2. Add a While Loop activity and set its condition to check whether or not the local variable you created is equal to true.
  3. Inside the loop, when you are ready for the loop to end, you can either set the local variable to false or use a Break activity.