Unify Logo Footer.svg
Unify Automations
Logo
List Operations: Create list, Add item to list, Add items to list, Modify item at index, Remove all items from list

List Operations: Create list, Add item to list, Add items to list, Modify item at index, Remove all items from list

Logo

3 mins READ

The Variable node treats a list as a first-class data type. Use the list operations to build up a collection during a loop, trim unwanted entries, or update a specific item at a known position — all without replacing the list wholesale.

Overview

A list is one of the types the Variable node supports alongside string, number, boolean, and object. A list can hold any value, and its items can themselves be lists, enabling 2D and 3D structures. The list operations let you grow, shrink, or modify a list variable incrementally. A common pattern is to initialize an empty list before a loop, then use Add item to list inside the loop to collect matching items as iterations run — because session variables persist across loop iterations within the same run.

Operations

Create list

Creates a list and allows you to specify a schema for its items. Define the list name, choose the item type (Object, String, Integer, Number, or Boolean), and configure the list schema. You can also use "Setup using JSON" to enter a predefined JSON schema directly. The schema is appended within the list's output data pill.

Add item to list

Appends or inserts a single item into a list variable. Specify the list name, the insert location (beginning or end of the list), and the list item field values. Items are added in the order the operation is called, making this the right tool for accumulating results inside a loop.

Add items to list

Appends multiple items to an existing list in a single operation. Specify the list name, the insert location (beginning or end of the list), a list item source (the source array for data mapping), and the list item field values. Use this for bulk addition when you have a source array of items to add at once rather than one at a time.

Modify item at index

Updates or removes an item in a list at a given index (0-based). Specify the list name, the operation mode, and the index to target.

  • Update item at index — Writes a new value at the specified position without changing the list's length. You also provide the new list item field values.

  • Remove item at index — Removes the item at the specified position from the list. After removal, the remaining items shift down to fill the gap.

Remove all items from list

Removes all items from an existing list, leaving the variable as an empty list. Specify the list name to clear. Use this before a conditional branch that should not carry forward items accumulated during a previous path through the automation.

Notes

Keep the following in mind when working with list variables.

  • List variables, like all session variables, live only for the duration of a single run and are not persisted across runs.

  • List variables persist across loop iterations within the same run — this is what makes the initialize-then-accumulate pattern reliable.

  • Sub-automations get their own isolated variables; a list variable in the parent is not accessible in a child sub-automation unless passed in explicitly.

  • There is no built-in increment for the Variable node. To bump a numeric value inside a list, read the item at its index, compute the new value, and write it back with Modify Item at Index.

  • If you need a list to survive between runs, write it to a Storage record instead.

For lists that grow large, confirm that the list size stays bounded across all likely inputs before deploying to production.

FAQs

Does removing an item shift the indices of remaining items?

Yes. When you use the Remove mode of Modify item at index, the items that followed the removed item shift down by one index position. Account for this if you are removing multiple items in a loop — removing by index while iterating forward can cause items to be skipped.

How do I get the current length of a list?

Retrieve the list variable with a Get operation and use your automation's expression tools to count the items. There is no dedicated list-length operation on the Variable node itself.

Can I use list operations on variables of other types - string, number, and so on?

No. Add item to list, Modify item at index, and Remove all items from list apply only to variables typed as a list. Attempting them on a variable holding a string or number will not produce the expected result.