List Type Variables
- Updated: 2020/05/06
List Type Variables
You can use a list type variable when you need to retrieve multiple values, one by one. It is basically one dimensional placeholder for data.
When/Why To Use a List Type Variable
Common uses of list variables include:
- Sending email to multiple recipients
- Passing different values inside of a loop
- Searching multiple web addresses
The values can represent either text or numeric data.
After you create the variable, you can use it by inserting the variable in several of the Workbench commands. When the value of the variable is modified, this value is reflected in any subsequent commands that are run by the task.
How to Create a List Type Variable
You can create list type variables in two ways: using direct assignment or using file assignment.
Direct Assignment
Create a list type variable using direct assignment when the values of the variable are fixed and need to be retrieved one-by-one as the task runs.
To create a list type variable using direct assignment, follow these steps:
- In the Workbench, click the Variable Manager icon at the top or on the tab on the right side.
- Click the Add button. The "Add Variable" window is displayed, with the "Create New Variable" option selected.
- Select type "List".
- Enter a name for the variable. The name must begin with an alphabetic character and cannot contain spaces.
- Select the "Value" radio button. This is the default.
- Specify list values in the field provided. The values can be character or numeric.
- Click the "Add to List" button.
- Repeat steps 5 and 6 to complete the list.
- Click Save.
You can use the "Make Random" check box to call the values randomly when the task runs.
If you leave the option unchecked, the values will be retrieved in the order you have entered them.
After the variable is saved, it is displayed in the Local Variables section of the Variable Manager.
Example of List Type Variable:
Name:
Email Address
Values: products@automationanywhere.com, support@automationanywhere.com, john.smith@automationanywhere.com
File Assignment
Create a list type variable using file assignment when the values for the variable need to be retrieved from a text file while a task is running.
The text file is used to define the list variable. Loop commands make it easy to process the list of values.
Common Use Case: Extract data to a text file
To create a list type variable using file assignment, follow these steps:
-
Determine the text file you will use for assigning values.
In the text file, ensure that the variable name exists, followed by an '=' operator, and a list of comma-separated values.
Example text file with list of values: Variable Name: products
The
products.txt
file contains:products = automation, testing, PI, SAP-automation, ERP-automation
- In the Workbench, click the Variable Manager icon at the top or on the tab on the right side.
- Click the Add button. The "Add Variable" window is displayed, with the "Create New Variable" option selected.
- Select type "List".
- Enter a name for the variable. The name must begin with an alphabetic character and cannot contain spaces.
- Select the "Read from text file" radio button.
- In the Select File field, browse to the file or type the file path for the required text file. Use the Open File button to view the selected text file.
- Click Save.
After the variable is saved, it is displayed in the Local Variables section of the Variable Manager.