Remove item action in List

Use the Remove item action to remove a specific item from a list variable based on its index position. The action stores the removed value in a variable that you specify.

Settings

  • Select the list variable from which to remove the item.
  • Enter the position of the item to remove 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

In this example, a bot cycles through a list of server endpoints. When the bot detects that an endpoint is returning errors, it uses the Remove item action to exclude that endpoint from subsequent retries.

  1. Create a user defined list variable $lstServers$:["https://api-east.example.com", "https://api-west.example.com", "https://api-eu.example.com"].
  2. The bot identifies that the endpoint at index 1 (api-west) is unresponsive. To remove it, configure the action with the following values:
    Field Value
    List variable $lstServers$
    Index number 1
    Assign the output to variable $sRemovedServer$
    Result:
    • $sRemovedServer$ = "https://api-west.example.com"
    • $lstServers$ = ["https://api-east.example.com", "https://api-eu.example.com"]
  3. After you execute the action, the remaining list items shift to fill the gap. The bot continues to loop through only the valid endpoints.
    Note: If the index number exceeds the list length, the action returns an error. Validate the list length before using this action in a loop.