Add to list
Function: Add to list
This action allows you to add a single item to an existing list of items. If you don't specify an existing list, a new list will be created for you, and the item will be added to it. This is useful for building collections of data, such as a list of products in an order, attendees for an event, or tasks in a project.
Input
- List (Optional, Type: Array) Select the list you want to add an item to. If you leave this empty, a new, empty list will be created automatically, and your item will be added to it.
- Item (Required, Type: Variable) Select the specific item you wish to add to the list. This can be any type of data, such as text, a number, a date, or even a complex object.
Output
- Result (Type: Array) This output represents the updated list after the item has been added. By default, this will update the original "List" variable you provided (or the newly created one). You can choose to store this updated list in a different variable if needed.
Execution Flow
Real-Life Examples
Here are some practical ways you can use the "Add to list" action in your applications:
Example 1: Building a Shopping Cart
Imagine you're building an e-commerce application where users can add products to their shopping cart.
- Inputs:
- List:
Shopping Cart Items(an existing list of products already in the cart) - Item:
New Product \(e.g., "Laptop Pro X", Price: $1200\)
- List:
- Result: The
Shopping Cart Itemslist now includes "Laptop Pro X".
Example 2: Compiling a Guest List for an Event
You're managing an event and want to keep a running list of confirmed attendees.
- Inputs:
- List: (Left empty, so a new list will be created)
- Item:
Guest Name \(e.g., "Alice Wonderland", Email: [email protected]\)
- Result: A new list, by default named
List, is created and now contains "Alice Wonderland". If you run this action again with another guest, that guest will be added to the sameList.
Example 3: Tracking Project Tasks
In a project management tool, you want to add new tasks to a specific project's task list.
- Inputs:
- List:
Project Alpha Tasks(a list containing tasks like "Design UI", "Develop Backend") - Item:
New Task \(e.g., "Write User Documentation", Status: "To Do"\)
- List:
- Result: The
Project Alpha Taskslist now includes "Write User Documentation" alongside the existing tasks.