Ask AI
Skip to main content

Add to list

Function: Add to list

This action allows you to manage collections of data by adding a new item to an existing list, or by creating a new list and adding the item to it. It's perfect for building dynamic lists of information within your application, such as a list of products, tasks, or user records.

Input

  • List
    • Description: Select the list you want to add an item to. If you leave this field empty, a new list will be created automatically.
    • Type: List of any type (ARRAY of VARIABLE)
  • Item
    • Description: Select the item you wish to add to the list. This can be any type of data, such as text, a number, or even a complex object.
    • Type: Any type (VARIABLE)
    • Required: Yes

Output

  • Result
    • Description: This variable will contain the list after the item has been added. You can give this output list a specific name. If you don't provide a name, the updated list will be stored in a variable named 'LIST' by default. Be aware that if you used an existing list as input and then leave this output field empty, the original input list will remain unchanged; instead, a new list named 'LIST' will be created or updated with the item.
    • Type: List of any type (ARRAY of VARIABLE)

Execution Flow

Real-Life Examples

Example 1: Adding a new product to an existing inventory list, storing the result in a new variable.

  • Scenario: You have a list of CurrentProducts and want to add a new Product to it. You also want to keep the original CurrentProducts list as is, creating a new UpdatedProducts list with the added item.
  • Inputs:
    • List: CurrentProducts (e.g., a list containing ["Laptop", "Mouse"])
    • Item: Keyboard
    • Result: UpdatedProducts
  • Result:
    • The CurrentProducts list remains ["Laptop", "Mouse"].
    • A new list variable named UpdatedProducts is created/updated, containing ["Laptop", "Mouse", "Keyboard"].

Example 2: Creating a new list and adding an item to it, using the default output name.

  • Scenario: You want to start a new list of Tasks for a project and add the very first task.
  • Inputs:
    • List: (left empty)
    • Item: Send welcome email
    • Result: (left empty, which defaults the output variable name to LIST)
  • Result: A new list variable named LIST is created in your application's memory, containing ["Send welcome email"].

Example 3: Adding a customer object to a list of leads, updating the original list variable.

  • Scenario: You have an existing list of NewLeads (each lead is an object with name and email) and you want to add a new customer record to this list, directly modifying the NewLeads list itself.
  • Inputs:
    • List: NewLeads (e.g., a list containing [\{"name": "Alice", "email": "alice@example.com"\}])
    • Item: \{"name": "Bob", "email": "bob@example.com"\} (an OBJECT representing a new customer)
    • Result: NewLeads (explicitly setting the output name to be the same as the input list name)
  • Result: The NewLeads list is updated to [\{"name": "Alice", "email": "alice@example.com"\}, \{"name": "Bob", "email": "bob@example.com"\}].