Iterator-related conditions

A loop iterator is a variable that keeps track of the current iteration within a loop. It is used to control the number of times the loop executes and to access elements in a list or array during each iteration.

For instance, if you are looping through a list of items, the loop iterator will help you access each item one by one until the loop completes. The Loop package provides several iterator conditions to control the iteration of loops.
Table 1. Loop iterators
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.

Use the Include all sub-folders option to recursively iterate through each sub-folder within a folder including hidden folders.

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 Microsoft 365 Calendar actions in a loop.
For each row in worksheet (Microsoft 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 work item in queue (Workload) Repeats the set of actions for each work item in a queue and assigns the work items to the Record variable. The Record variable returns three fixed key values namely workitemId, workitemValues, and workitemMetadata. See Using the For each work item in queue iterator
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.