Get item action in List
- Updated: 2024/06/28
Get item action in List
You can retrieve a value at the specified position in a list and store the output to a variable using the Get item action.
Settings
- Select the list variable from which you want to retrieve a value from the List variable list.
- Specify the position in the list from where you want to retrieve the value in the Index number field. The list index starts from 0. The first item in the list is at position 0, the second item at 1, and so on.
- Select a variable that you want to use to store the output from the Assign the output to variable list.
Example of using Get item action
For example, to create a bot to retrieve data from a list where you want to see data from sales of
the iPhone14 on product launch day, perform the following steps:
- Create a bot.
- On the left panel, click Automation.
A list of available bots and forms is displayed.
- Click Create a bot.
- Enter the bot name: List_Get_item.
- Click Create and Edit.
- On the left panel, click Automation.
- Create the user-defined variables using the Create variable (+) icon at the top of the
Variables menu.
- Create a variable of List type and select the datatype Any to include any data of subtypes (String, Boolean, Number, Datetime, or File).
- Select the type and enter the following values:
Type Value Datetime 6/15/2023 Number 100 String Customer footfall String Apple Oakridge - San Jose store String Phone type - iPhone String iPhone 14 pro max String iPhones sold - 10 Qty Boolean true
- To retrieve a value at a specified position in a list, double-click or drag the action from the Actions pane.
- In the List variable field, select CustomerData.
- In the Index number field, enter 1 to specify the position in the list from where you want to retrieve a value.
- To store the output, select SampleNumber from the Assign the output to variable listfield.
- To print the value of the Index 1, double-click or drag the Message box action. Enter the value $CustomerData[1].Number:toString$ in the Enter the message to display field.
- Click Save and then Run.
The bot displays the position one index data of the list variable (100).
- Repeat Step 3.
- Drag the action.
- Select the Variable option from the Source date and time variable field.
- Select SampleString from Assign the output to a variable field.
- To print the values, drag the Message box. Enter the following values in the Enter the message to display field:
- $SampleString$
- $CustomerData[1].Number:toString$
- $CustomerData[2]$
- $CustomerData[3]$
- $CustomerData[4]$
- $CustomerData[5]$
- $CustomerData[6]$
- $CustomerData[7].Boolean:toString$
- Click Save and then
Run.
The output is displayed as:
The output shows that on June 15, 100 customers visited the Apple store in San Jose on the product launch day, and ten iPhones were sold. The true value indicates that iPhone is the best-selling smartphone of 2023.