Read and Review Automation Anywhere Documentation

Automation 360

Close Contents

Contents

Open Contents

Loop package

  • Updated: 11/09/2021
    • Automation 360 v.x
    • Build
    • RPA Workspace

Loop package

Use the Loop package to run a sequence of actions repeatedly for a specific number of times or until a specific condition is met.

The Loop package enables you to repeatedly run specific actions within a bot. For example, 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 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.

Actions in the Loop package

The following Loop actions are available:

Action Description
Loop Repeats the action for a specific number of times based on the option selected from the Iterator list, or until the condition is met based on the option selected from the Condition list. See Using Loop action.
Continue Use the Continue action along with the If action to skip the current iteration and continue with the next iteration in the loop based on the condition you have specified in the If action. See If package.
Break You can use the Break action along with the If action to terminate the loop based on the condition you have specified in the If action. When you terminate the loop, the actions immediately following the Loop action run. See If package.

Iterator-related conditions within the Loop action

Select the Iterator option to specify the number of times the set of actions will be repeated as part of the Loop action:

Iterator Description
For each row in CSV/TXT Repeats the set of actions for each row in the specified CSV or text file and assigns the values in the current row to a record variable. See Using the For each row in CSV/TXT iterator.
For each row in Data Table Repeats the set of actions for each row in the specified table and assigns the values in the current row to a record variable. See Using the For each row in table iterator.
For each row in a SQL query dataset Repeats the set of actions for each row in the specified SQL query dataset and assigns the values in the current row to a record variable. Provide the session name that you have used to establish a connection with the database.
For each key in the Dictionary Repeats the set of actions for each key in the specified Dictionary variable and assigns the name of the current key to a variable.
Note: When a bot runs a Loop action that contains a Dictionary > Put action, the bot only iterates on the original number of items in a dictionary; it ignores items inserted using the Put action.
For each value in the Dictionary Repeats the set of actions for each value in the specified Dictionary variable and assigns the current value to a variable. Because this variable type can hold various subtypes (String, Number, Boolean, and so on), if you quick-create a variable when configuring the action, the variable is of Any type.
Note: When a bot runs a Loop action that contains a Dictionary > Put action, the bot only iterates on the original number of items in a dictionary; it ignores items inserted using the Put action.
For each mail in mailbox Repeats the set of actions for each email in the specified mailbox. See Using the For each mail in mail box iterator.
For each row in worksheet (Excel basic or Excel advanced) Repeats the set of actions for each row that contains data in a worksheet and assigns the values in the current row to a record variable. Provide the session name that you have used to open the Excel basic or Excel advanced worksheet. Specify whether to repeat the actions for all the rows, specified rows, or a specified cell range. Select a record variable from the Assign the current row to this variable list or create a new one. See Record variable.
This iterator retrieves cell values as string data types. It supports Excel cell formats, including Number, Percentage, Currency, Scientific, and Date. For example, a value from a cell of Currency formatting retains the currency symbol when passed to a table or record variable.
  • You must convert the values to perform non-string operations.
  • In Excel advanced, when you choose loop iterator as For each row in worksheet, you have a Read option to read either the visible text or value of the cell.

    For example, if the cell has 70% as cell content, Read cell value option will read the value as 70 ignoring the % format whereas Read visible text option will read the content as 70%.

    Recommendation: Use the Read cell value option as reading value from a cell for better performance than reading visible text.

Use of Global session option to share an Microsoft Excel session using the Excel advanced package is not available with this option.

Alternate solution: Use the Get multiple cells action and save the data into a datatable variable and then, use the Loop package with the Data Table option selected.

For each file in folder Repeats the set of actions for each file in the specified folder and assigns the properties of the current file to a Dictionary variable containing two keys: the name key holds the file name and the extension key holds the file extension.

To open files with different extensions, use the variable option to assign the folder path, file name, and file extension . First, create a variable for the folder path, $sFolder$. Then, for the files in the folder path, create two variables, one for file name $name$ and another for file extension $extension$. To open a file, combine the variables as a string, such as $sFolder$\$name$.$extension$. For the extension to work with different file types and different open options, you can add conditional logic.

For each folder in folder Repeats the set of actions for each folder in the specified folder and assigns the current folder name to a String variable.
For each item in the list Repeats the set of actions for each item in the specified list and assigns the current item to a variable. Specify whether to repeat the action for all items in the list or only for the range of items in the list. Because this variable type can hold various subtypes (String, Number, Boolean, and so on), if you quick-create a variable when configuring the action, the variable is of Any type.
Note: The index in a list starts from zero. For example, to repeat the action for items from the third position to the sixth position of the list, specify 2 and 5 in the appropriate fields.
For n times Repeats the actions in the container the specified number of times. You can assign the iteration count to a Number variable.
For each value in record Repeats the actions for each value in the specified record and assigns the current value to a variable. Because this variable type can hold various subtypes (String, Number, Boolean, and so on), if you quick-create a variable when configuring the action, the variable is of Any type..
For each meeting in calendar Use this option to repeat the set of actions for each meeting in the specified calendar. See Using Office 365 Calendar actions in a loop.
For each row in worksheet (Office 365 Excel) Repeats the set of actions for each row that contains data in a worksheet.
  • Provide the session name that you have used to open the worksheet.
  • Specify whether to repeat the actions for all the rows or specific rows.
  • You can assign the values in the current row to a record variable.
For each node in a XML dataset Repeats the set of actions for each node in an XML dataset and assigns the current node to String variable. Provide the session name that you have used to open the XML file.

While related conditions in the Loop action

You can configure multiple while related conditions within a single Loop action:
  1. Click Add condition.
  2. Select either of the following options:
    • And: Both of the conditions must be met for the actions to run.
    • Or: Either of the conditions must be met for the actions to run.
  3. Select the conditions from the drop-down list.
Select the While option to use the following conditions:
While Description
Application Use the Application is not running or Application is running condition to execute actions based on whether an application is running or not running.

Enter the application path or specify the path using a variable along with the amount of time to wait (in seconds) for the condition to be true.

Boolean Use this condition to execute actions based on the value of a Boolean variable. Use this condition to compare the values of two Boolean variables or one Boolean variable to a selected Boolean value.
Data table Use the Data table is empty condition to execute actions based on whether the specified table contains values.

Use the Number of rows and Number of columns conditions to execute actions based on whether the number of columns or rows is Equal to, Greater than, or Less than the specified value.

Datetime Use the Datetime variable condition to execute actions based on whether the value of the source datetime variable is Equal to or Not Equal to, is Greater than or Equal to, or is Lesser than or Equal to the value of the target datetime variable.
Dictionary Use this condition to repeat the set of actions based on whether the selected dictionary variable contains the specified key.
Note: The key comparison is case-sensitive.
File Use the following conditions to execute the action:
  • File date

    Use this condition to verify the date and time that the specified file was created or modified. Specify a date range using the Is within last, Is between, or Is before options. For the Is within last option, specify the number of days or time (in hours, minutes, and seconds). Enter the amount of time (in seconds) to wait for this condition to be true.

  • File exists and File does not exist

    Use these conditions to execute an action based on whether a file exists. For example, if a data file exists, format the file and upload it to a database.

  • File extension

    Use this condition to check the file extension of a selected file and then execute actions based on the results. Use the File path field to select a file.

  • File size

    This condition verifies if the specified file is larger, smaller, not the same, or the same as the size you specify.

    Enter the amount of time (in seconds) to wait for this condition to be true.

Folder does or does not exists Use these conditions to repeat the set of actions based on whether a folder exists.
Image Recognition Use these conditions to verify whether:
  • Image file is found in the Image file or not.
  • Image file is found in the Window or not.
  • Window is found in the Image file or not.
  • Window is found in the Window or not.
For the Window conditions, you can use the Resize window option to specify the window dimensions. This option delivers a more reliable bot. It resizes the window to the dimensions at which the task was recorded, which enhances the bot's ability to identify the target object.
Note: This option is only available for windows that can be resized. It is not available for Desktop or Taskbar options.

For the Window conditions, you can use the Preview option to select a specific captured occurrence and position your click location relative to the image.

JavaScript Use the Script is successful or Script is unsuccessful condition to execute actions based the status of the specified JavaScript. Select the file that contains the script and optionally specify the parameters by selecting a list variable.
Legacy automation The Legacy automation conditions are only used in migrated bots to ensure that they run seamlessly in Automation 360. We do not recommend using these conditions for new bot development. The following conditions to verify the following:
  • Whether Web control exists or not.
  • Whether Window control exists or not.
  • Whether Window control is active or not.
  • Whether Script is successful or not.
  • Whether Child window exists or not.

For the Window control conditions, you can use the Resize window option to specify the window dimensions. This option delivers a more reliable bot. It resizes the window to the dimensions at which the task was recorded, which enhances the bot's ability to identify the target object.

List Use the List variable condition to execute actions based on whether the specified list variable contains a particular value. The value can be of Number, String, or Boolean data type.
Number Use the Number variable condition to execute actions based on whether the specified number variable is Equal to or Not Equal to, or is Greater than or Equal to, or is Lesser than or Equal to a particular value.
Ping Use the Ping is successful or Ping is unsuccessful condition to verify if a machine or server is running, and execute actions based on the result. Enter the amount of time (in seconds) to wait for the condition to be true.
Recorder
  • Use the Object exists condition to detect an object in a window. Select a window or variable to capture the object. Enter the amount of time (in seconds) to wait for this condition to be true, that is, for the object to be detected.
  • Use the Object does not exist condition to verify whether a specific object exists in a window, and then based on the result, execute actions. Enter the amount of time (in seconds) to wait for this condition to be true. For example, you can use the Object does not exist condition inside the Loop > While condition to make sure that the bot does not execute the next action until the object on the business application is loaded.
Service Use the Service is running or Service is not running condition to execute actions based on whether a service is running or not. Select Service list to choose a service from the list of available services.
String Use the String variable condition to execute actions based on whether the specified source string value is Equal to or Not equal to, or Includes or Does not include the target value.

You can select the Match case option to only execute actions if the two strings have matching uppercase and lowercase letters.

When you extract text from a Microsoft application, the extracted text contains the /r/n special characters which indicate a new line. Select the Ignore Carriage return option if you want to ignore the /r special character when you compare the text.

To create a condition based on whether a string is empty or not empty, compare the source value to an empty target field using the Equal to operator.

See Example of using a conditional statement.

Task Bot Use the Task successful or Task unsuccessful condition to execute actions based on the status of the specified Task Bot.
VBScript Use the Script is successful or Script is unsuccessful condition to execute actions based on the status of the specified Visual Basic script. Select the file that contains the script and optionally specify the parameters by selecting a variable.
Window Use the Window exists or Window does not exist condition to verify if a specific application window is open by entering the Window title or using a variable. Enter the amount of time (in seconds) to wait for the condition to be true.

Use the Window with same title does not exist or Window with same title exist condition to verify whether a window with the same title exists or whether the window title has changed. Enter the amount of time (in seconds) to keep verifying if the condition is true.

Send Feedback