While loops are one of the two types of loops available in SecureX orchestration. This type of loop will continue running as long as its control condition is true. If you want to loop through a list of objects in a table, you should look at the
For Each Loop.
- You can stop a loop using the
- You can skip the rest of a single iteration of a loop using the
While loops run as long as their control condition is true. This control condition works the same as a
Condition Block in that it’s simply checking a logical statement. You can either:
- Set this condition to something that will always be true and use a
Breakto stop the loop; or
- Use a loop control variable that you change the value of when you want the loop to end.
Be careful! If you forget to stop a while loop, it will keep running for quite a while before stopping… If you’re iterating through a list of items, it’s usually better to use a
For Each Loop.
- Create a local variable using the
Booleandata type and set its value to
- Add a
While Loopactivity and set its condition to check whether or not the local variable you created is equal to
- Inside the loop, when you’re ready for the loop to end, you can either set the local variable to
falseor use a
The following sample workflows are available in our repository’s workflows folder to help you get familiar with this activity. These can be imported using the instructions here or you can view the workflow in GitHub by clicking on it.