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:
  1. Create a bot.
    1. On the left panel, click Automation.

      A list of available bots and forms is displayed.

    2. Click Create a bot.
    3. Enter the bot name: List_Get_item.
    4. Click Create and Edit.
  2. Create the user-defined variables using the Create variable (+) icon at the top of the Variables menu.
    1. Create a variable of List type and select the datatype Any to include any data of subtypes (String, Boolean, Number, Datetime, or File).
    2. 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
  3. To retrieve a value at a specified position in a list, double-click or drag the List > Get item action from the Actions pane.
    1. In the List variable field, select CustomerData.
    2. In the Index number field, enter 1 to specify the position in the list from where you want to retrieve a value.
    3. To store the output, select SampleNumber from the Assign the output to variable listfield.
  4. 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.
  5. Click Save and then Run.

    The bot displays the position one index data of the list variable (100).

  6. Repeat Step 3.
  7. Drag the Datetime > To String action.
    1. Select the Variable option from the Source date and time variable field.
    2. Select SampleString from Assign the output to a variable field.
  8. 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$
  9. Click Save and then Run.

    The output is displayed as:

    Printed values of the variables

    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.