Execute a code until a specified condition is true using the While component in RPA Desktop Design Studio.

Watch this video to learn how to use the While component.

Before you begin

Role required: none

About this task

You can configure the properties for the While component.

Procedure

  1. In the Toolbox pane, navigate to Loops > While.
  2. Drag the While component to the Design surface.
  3. Double-click the light-yellow colored field (Light-yellow-colored-field) under the WHILE component bar.
  4. Enter the condition.
    A Data In port is dynamically added for the parameter that contains the While condition.
  5. Connect the data and control ports of the While component to the corresponding ports of the other components as described in the following table.
    Port name Purpose of connection Port type Data type
    The name of the port is the same as the name of the parameter that defines the condition. Takes the value of the parameter. The component matches the value with the condition.

    For example, i<=10.

    Data In Object
    ControlOut Use the port at the end of the While Loop to continue to the next action flows. Control Out
    LoopPort Use the port to perform actions inside the While Loop (such as calculating expressions, logging values, and so on). Control Out
  6. (Optional) To test the component, under the DESIGN tab, click Run.

Example: While component

Drag Variable component before the While component. Add Expression component and MessageBox components after the While component. In the Variable component, enter 1. In the Expression component, enter i+1. Set a Breakpoint at the Expression component. In the While component, enter i<=10.

When you run this automation, the value 1 is incremented to 2 and shows in the output, MessageBox, as 2. When you select Move next on the Design tab, the value is incremented until 11. Since the condition matches at this point, i<=10, the loop ends and automation is ended.
Figure 1. While component
While component with Variable, Expression, and MessageBox components showing an automation.