Create a Conditional LOOP

A LOOP repeats the same action(s) for a specified number of times.

A Conditional LOOP adds a statement to the LOOP. The Bot checks whether this statement is TRUE or FALSE, either before or after an action.

You can specify any kind of sequence in Conditional LOOPs:

  • First the statement, then the action(s)

  • First the action(s), then the statement

  • Action(s), statement, action(s)

The Bot performs the loop for the specified number of times or until the statement is FALSE, whichever comes first.

If you are an avid coffee drinker, you might be familiar with the following Conditional LOOPs:

Conditional LOOPs: different sequences

A Conditional LOOP consist of the following elements:

Element

Description

Control Expression

Statement that the Bot should check.

Step(s)

Action(s) that the Bot performs.

Work with Control Expressions

A Control Expression is a statement that the Bot should verify.

Typically, this statement consists of the following elements:

  • a Value Expression that you compare with the help of

  • an operator (==, !=, <, >, <=, or >=) to

  • a text, a number, or another Value Expression

For instance: {B[Buffer1]} == {B[Buffer2]} checks whether the value of the Buffer Buffer1 is the same as that of Buffer2.

Whenever you work with numbers or dates, ensure that you have set the correct date and number format for RPA Studio.

Use Modules in Control Expressions

Alternatively, you can use a Module in the Control Expression, provided that the resulting Step contains a verification.

For instance, you can use a Module that you created by scanning a table to check whether a specific row exists. If it doesn't, the Bot should stay in the LOOP (see the example below).

To add a Module to a Control Expression, click on Add within the Control Expression and select a Module in the subsequent dialog.

Add a Module to a Control Expression

You can also drag and drop an existing, filled-out Step onto the Control Expression, provided that this Step was created from a Module.

To remove the Module, click on the Control Expression and delete the Module from the Details tab.

If you want to use the Module in a different place in your Flowchart, drag and drop it from the Details tab into the Flowchart.

Module in a Control Expression

Special characters and wildcards

RPA Studio supports special characters and wildcards in Control Expressions. For information on how to use them, see "Use special characters" and "Use wildcards".

Add a Conditional LOOP to your Bot

To add a Conditional LOOP, follow the steps below:

  1. In the Flowchart tab, click on Add.

  2. In the Logic tab of the subsequent dialog, click on Conditional LOOP.

  3. In the Flowchart, enter a name for your Conditional LOOP into the <New Loop> entry field.

  4. Define the statement that the Bot should check. To do so, enter your statement into the <expression> entry field.

    Alternatively, use a Module as described above: "Use Modules in Control Expressions".

  5. If you don't use a Module, set an appropriate data type for the Control Expression.

    To do so, go to the Details tab and select one of the following options from the DataType drop-down menu:

    • String to process a string

    • Date to process date values

    • Numeric to process numbers

Select a data type for the Control Expression

  1. Add a Step to your Conditional LOOP by clicking on Add.

    You can use a Module to create this Step, or you can add another Logic element.

  2. Add as many Steps as needed.

  3. Define the sequence of your Conditional LOOP by arranging the Control Expression and action elements via drag and drop.

  4. Optionally, define how many times the Bot should repeat the defined Step(s). To do so, navigate to the Details tab and enter a positive integer into the Value field of the Control Expression. The Bot performs the Conditional LOOP the specified number of times or until the statement is FALSE, whichever comes first.

    You can also enter Buffers, for instance if you saved the row count of a table.

Let's say you have a table in your application. This table is several pages long. The Bot should find a specific row; if it can't find this row on a page, the Bot should click the Next button and search the next page.

This process should repeat until the Bot finds the row.

To do so, follow the steps below:

  1. Scan your table to create a Module.

  2. Add the Conditional LOOP.

  3. Click on Add within the Control Expression.

  4. In the subsequent dialog, select the Module that you created in step 1.

  5. Fill out the Step Values (see "Work with tables").

    In this example, the Bot limits the search to any row that has ALL of the following cells:

    • A cell in the column First Name with the value Jane

    • A cell in the column Last Name with the value Smith

    • A cell in the column DOB with the value 01/01/1975

    The Bot verifies that this row does not exist.

Search for a row by specific criteria

  1. Add the Step that defines what the Bot should do if the Control Expression is TRUE, i.e. if the row doesn't exist.

Conditional LOOP with Module: Control Expression in the Flowchart and in the Details tab

Use multiple Control Expressions

You can add multiple statements to the same Conditional LOOP. To do so, follow the steps below:

  1. In the Conditional LOOP, click on Add.

  2. In the Logic tab of the Add dialog, select Condition.

Add dialog: select Condition

Was this information helpful?

Tricentis RPA Studio Manual 2020.2 © Tricentis GmbH