Loop package
- Updated: 2024/08/05
Loop package
Use the Loop package to repeat a set of actions multiple times based on specified conditions. It allows you to iterate over a list, a range of numbers, or until a specific condition is met, making it useful for tasks that require repetitive actions.
For instance, repeat the set of actions that read data from each row of a Microsoft Excel file, rename all files in a folder, and save each email in a mailbox. You can also use the If action within the Loop action to validate a condition, and based on the outcome of it, skip the current iteration in the loop or even break the loop. For more information on using the If action, refer to the If package documentation.
For conditional loops, different actions are taken depending on whether the conditional parameters are met. For loops that have a specified number of iterations, the loop exits on the last iteration and goes to the next step in the bot.
- You enter the dynamic values of the column count as the end condition in the loop.
- Inside the loop body, use the action to delete the column at index 0.
- When you run the bot, it deletes a column in each iteration.
Labeling loops for automation control
- Ensure that each loop label in a specific bot is unique.
- The Label field supports only alphanumeric characters.
- In the Label field of the first Loop action, specify a label as
outerloop
. - In the Label field of the second Loop action, specify a label as
innerloop
. - In the action, in the Label field, select the label of the loop from which you want to continue.
- In the action, in the Label field, select the label of the loop from which you want to break.
Click the video to see how labeling loops work.
In a bot, if you have multiple nested loops with and Break actions, and if you have not labeled the loops, then on bot execution, the bot breaks or continues the nearest loop by default.
- An outer loop and an inner loop nested within the outer loop.
- A Break action within the inner loop. and
Actions in the Loop package
The following Loop actions are available:
Action | Description |
---|---|
Loop | See Using Loop action. |
Continue |
See Continue action. |
Break |
See Break action. |