The loops allow checking for dependencies between variables, actions, and conditions. They are used to repeat a particular sequence of actions several times.
To set a loop, drag it from the Palette tab to the activity you need to create the loop after, fill in the required fields, and click Save. Add the required activities inside the loop.
To delete a loop from the process diagram, click the button in the lower right corner of the loop settings window or click the
button to the left of the loop.
You can create escalation for each loop using the button. Read more about escalation in the "Execution flow" article.
For your convenience you can collapse elements inside the loop. To do this, click the button.
While
The While loop allows performing a particular sequence of actions until the set condition is met. If the condition is not met, the loop terminates. For example, you need to process all the new contractors. The set sequence of actions is performed as long as the number of new contractors is greater than 0.
You can use the loop to check the request statuses. For example, the bot creates a new request in the Oracle system. The status is checked in a loop. As soon as the request gets the “Completed” status, the loop terminates, and the process goes on.
To avoid an infinite loop, add an activity changing the condition to the loop body.
The loop settings window is displayed in the picture below.
- Name *. The loop name on the process diagram.
- Sequence flow. The condition for performing a sequence of actions in the loop.
As a condition, you can use a website’s or an application’s availability, or a context variable:
- Address. The URL of the website that should be accessible in order for the loop to occur;
- Program. The name of the program that should be accessible for the loop to occur;
- Property. The flow takes the loop as long as the context variable value corresponds to the set condition. The variable is compared to another variable or its precise value is set with operators. Available comparison operators are similar to the operators used for XOR gateway settings.
In the Property field, specify the context variable the condition is set for and the element it will be compared with:
- Property. The variable will be compared with another context variable;
- Value. The variable will be compared with an exact value.
For each
The For each loop allows performing a particular sequence of actions for every element set in the array. Read more about working with the array in the "Process context" article.
For example, you need to specify the person in charge of every new contractor. Every new contractor is a separate array element value.
You can use the loop to process the received files stored in an array. For example, you can check statuses of the 1C documents by the stored numbers.
The loop settings window is displayed in the picture below.
- Name *. The loop name on the process diagram.
- Array. Select a variable that stores the array elements.
- Iterator variable. Select a variable that that iterates through each of the values specified in the array during loop execution.
Each value is processed separately. The set sequence of actions will be performed for all the array elements.
For each element
The For each element loop allows performing a particular sequence of actions for every selected interface element. The loop is executed for the elements, whose parameters are set in the Control box.
For example, when you work with tables in 1C, you need to perform certain actions for each entry in the table. You can select a table entry and use regular expressions to set the elements the bot has to find. In this case, the bot will perform the set sequence of actions for each entry.
The loop settings window is displayed in the picture below.
Name *. The loop name on the process diagram.
Variable with a name. Select a variable that stores an interface element name every time the loop is iterated.
Variable with a type. Select a variable that stores an interface element type every time the loop is iterated.
Variable with a value. Select a variable that stores an interface element value every time the loop is iterated.
The element name, type, and value are set in the Control box. The value is specified in the Text field.
The settings window displays a screenshot of the target interface element with which the interaction is configured. You can set the search method, the number of search attempts and the interval. The same settings are configured when you work with activities. Read more about activity settings in the "Basic activity settings principles" article.
Control box
In this box, you can set the interface elements for the loop execution. For example, in the Name field, you can use a regular expression to set a name template. The bot will use it to search for the required elements. The element parameters are set in the same way as when you work with activities. Read more about the parameters in the "Basic activity settings principles" article.
Nested loops
You can create nested loops. A loop can contain only two loops inside. The loop coloring helps you define their nesting levels:
- Green. The loop is not nested in other loops;
- Blue. The loop is nested in another loop;
- Yellow. The loop is nested in two other loops.
Found a typo? Highlight the text, press ctrl + enter and notify us