Ask AI
Skip to main content

Get an object from a list

Function: Get an object from a list

This action allows you to retrieve a specific item from a collection of items (a list) based on its position. It's useful when you have a structured list of data and need to pinpoint and work with one particular entry, such as a specific product from a catalog or a task from a project plan.

Input

  • List: The collection of items you want to search through. This could be a list of customers, products, tasks, or any other structured data. (Type: ARRAY)
  • Index: The position number of the item you want to retrieve from the list. Remember that in most systems, the first item in a list is at position 0, the second at position 1, and so on. This input is required. (Type: NUMBER)

Output

  • Result: The specific item found at the given index within your list. This item will be an object containing all its properties. If the index is out of bounds (e.g., you ask for item at index 5 in a list with only 3 items) or the list is empty, no item will be returned. (Type: OBJECT)

Execution Flow

Real-Life Examples

Example 1: Getting a specific product from a product catalog Imagine you have a list of products displayed on your website, and you want to highlight the second product in that list on a special offer banner.

  • Inputs:
    • List: ["Laptop Pro", "Wireless Mouse", "Mechanical Keyboard", "4K Monitor"]
    • Index: 1 (to get the second item, as lists start counting from 0)
  • Result: The action retrieves the item "Wireless Mouse".

Example 2: Accessing a specific task in a project plan You have a list of tasks for a project, and you need to update the status of the very first task.

  • Inputs:
    • List: [\{"TaskName": "Design UI", "Status": "Completed"\}, \{"TaskName": "Develop Backend", "Status": "In Progress"\}, \{"TaskName": "Test Application", "Status": "Pending"\}]
    • Index: 0 (to get the first item)
  • Result: The action retrieves the task object \{"TaskName": "Design UI", "Status": "Completed"\}.

Example 3: Finding a customer record from a filtered list After filtering your customer database, you have a short list of customers and you want to examine the third customer's details.

  • Inputs:
  • Result: The action retrieves the customer record \{"CustomerID": "C005", "Name": "Eve", "Email": "[email protected]"\}.