Lists
Built-in step · 24 steps
Count, sort, combine, and clean up lists and records.
Steps
| Step | What it does |
|---|---|
| Add item to end | Add an item to the end of a list. |
| Check if list includes item | Check whether a list includes a specific item. |
| Combine two lists | Merge two lists into one, keeping the items of the first list followed by the items of the second. |
| Compare two lists | Find what two lists have in common and where they differ: what is only in the first, only in the second, in both, and, for records matched by a field, which ones changed. |
| Count different values | Count how many different values a list holds, or how many different values one field takes, like how many customers placed the orders. |
| Count items | Count how many items are in a list. |
| Create a list | Create a list by entering its items one by one. |
| Edit a record | Keep only some fields of a record, remove fields, rename them, or merge in another record. |
| Filter list | Keep only the items in a list that match a condition, and return them as a new list. |
| Find item position | Find where an item appears in a list. |
| Get first item | Get the first item of a list. |
| Get last item | Get the last item of a list. |
| Get one field from every item | Turn a list of records (spreadsheet rows, orders) into a list of one field's values, such as every row's Amount, so you can total, average or join them. |
| Group items by a field | Sort a list of records into groups that share the same value in one field, such as each owner's tasks. |
| Insert item | Add an item at a specific position in a list. |
| Match records from two lists | Add the fields of the matching record in a second list to each record, like a spreadsheet lookup (VLOOKUP): each order gets its customer's name and plan, matched by email. |
| Remove an item | Remove an item from a list wherever it appears. |
| Remove duplicates | Remove repeated items from a list, or records that repeat a field, like two rows for one email address. |
| Remove item by position | Remove the item at a specific position in a list. |
| Reverse list | Reverse the order of items in a list. |
| Shuffle list | Put the items of a list in a random order. |
| Sort list | Sort a list in ascending (first/smallest to last/largest) or descending (last/largest to first/smallest) order. |
| Split a list into batches | Split a list into smaller lists of a set size, for an app that takes so many items at a time. |
| Take part of list | Take a section of a list, such as the first five items or the last three. |
Add item to end
Add an item to the end of a list.
Inputs
- List
itemslistRequired - The list to add the item to.
- Item to add
valueobjectRequired - The item to add. A list is added as a single item.
Outputs
The list with the item added at the end.
Example output
[
"apples",
"bananas",
"cherries"
]Check if list includes item
Check whether a list includes a specific item.
Inputs
- List
itemslistRequired - The list to search.
- Item to check
valueobjectRequired - The item to look for. It must match an item exactly.
Outputs
Whether the list includes the item.
Example output
trueCombine two lists
Merge two lists into one, keeping the items of the first list followed by the items of the second. Leave the second list out to merge the lists inside one list into a single list (flatten).
Inputs
- First list
firstlistRequired - The list whose items come first.
- Second list
secondlist - The list whose items come after the first list's. Leave it empty when the first list holds lists to merge into one, like the results a loop gathered.
Outputs
One list: the first list's items followed by the second list's.
Example output
[
"apples",
"bananas",
"cherries",
"dates"
]Compare two lists
Find what two lists have in common and where they differ: what is only in the first, only in the second, in both, and, for records matched by a field, which ones changed. Handy for keeping two apps in sync.
Inputs
- First list
firstlistRequired - One list, like the rows of a spreadsheet.
- Second list
secondlistRequired - The list to compare it with, like an app's contacts.
- Match records by
fieldtext - For lists of records, the field that says two records are the same one, like Email or ID. Letter case and spaces don't matter. Leave empty to compare whole items.
Outputs
Four lists: only_in_first, only_in_second, in_both (items from the first list), and changed: each matching pair holding a different value in a field both have, as first, second and the names of the fields that differ.
changedlist- Records in both with a different value in a field both have, each as first, second and fields.
in_bothlist- Items both lists have, as the first list holds them.
only_in_firstlist- Items only the first list has.
only_in_secondlist- Items only the second list has.
Example output
{
"changed": [
{
"fields": [
"plan"
],
"first": {
"email": "ben@example.com",
"plan": "pro"
},
"second": {
"email": "ben@example.com",
"plan": "free"
}
}
],
"in_both": [
{
"email": "ben@example.com",
"plan": "pro"
}
],
"only_in_first": [
{
"email": "ana@example.com"
}
],
"only_in_second": []
}Count different values
Count how many different values a list holds, or how many different values one field takes, like how many customers placed the orders. Blanks don't count.
Inputs
- List
itemslistRequired - The list, or list of records, to count.
- Field
fieldtext - For a list of records, the field to count the different values of, like Customer email. Letter case and spaces don't matter.
Outputs
How many different values there are.
Example output
12Count items
Count how many items are in a list.
Inputs
- List
itemslistRequired - The list to count the items of.
Outputs
The number of items in the list.
Example output
3Create a list
Create a list by entering its items one by one.
Inputs
- Items
itemslistRequired - The items to put in the list, in order.
Outputs
The new list, with the items in the order entered.
Example output
[
"apples",
"bananas",
3
]Edit a record
Keep only some fields of a record, remove fields, rename them, or merge in another record. Given a list of records, like spreadsheet rows, it edits each one.
Inputs
- Record
recordtextRequired - The record, or list of records, to edit.
- What to do
edittextRequired - How to change the record.One of:
keep(Keep only some fields),remove(Remove fields),rename(Rename fields),merge(Merge in another record). Default:keep. - Fields
fieldslist - The names of the fields, like Name and Email. Use dots to reach inside, like address.city.Only when What to do is Keep only some fields or Remove fields.
- New names
renamesobject - Each field's current name, and the name to give it.Only when What to do is Rename fields.
- Record to merge in
othertext - Its fields are added; where both records have a field, its value is the one kept.Only when What to do is Merge in another record.
Outputs
The edited record, or the list of edited records when a list was given.
Example output
{
"email": "ana@example.com",
"name": "Ana"
}Filter list
Keep only the items in a list that match a condition, and return them as a new list. Build the condition the same way as an “If” step, referring to the current item as “item”.
Inputs
- List
itemslistRequired - The list to filter. The condition reads each item in turn as item.
- Keep item if
conditiontextRequired - Only items for which this is true are kept. Refer to the current item as “item” (for example, item.price is greater than 100).
Outputs
The items that meet the condition, in their original order.
Example output
[
{
"price": 150,
"sku": "B2"
},
{
"price": 300,
"sku": "C3"
}
]Find item position
Find where an item appears in a list. Returns -1 if it is not found.
Inputs
- List
itemslistRequired - The list to search.
- Item to find
valueobjectRequired - The item to look for. It must match an item exactly.
Outputs
The position of the first matching item, counting from 0, or -1 if the item is not in the list.
Example output
1Get first item
Get the first item of a list. If the list is empty, returns an empty list (shown as “Empty list”).
Inputs
- List
itemslistRequired - The list to take the first item from.
Outputs
The first item in the list, of whatever type it is, or an empty list if the list has no items.
Example output
{
"email": "ana@example.com",
"id": 101
}Get last item
Get the last item of a list. If the list is empty, returns an empty list (shown as “Empty list”).
Inputs
- List
itemslistRequired - The list to take the last item from.
Outputs
The last item in the list, of whatever type it is, or an empty list if the list has no items.
Example output
{
"email": "ben@example.com",
"id": 102
}Get one field from every item
Turn a list of records (spreadsheet rows, orders) into a list of one field's values, such as every row's Amount, so you can total, average or join them.
Inputs
- List of records
itemslistRequired - The list of records (objects), such as spreadsheet rows or an earlier step's results.
- Field
fieldtextRequired - The name of the field or column to take from every record, for example Amount.
Outputs
The field's value from each record, in the same order, with null where a record has no value for it.
Example output
[
"12.50",
"100",
null
]Group items by a field
Sort a list of records into groups that share the same value in one field, such as each owner's tasks. Each group has a key (the shared value), its items, and a count. Text matches ignoring case and spaces; records with a blank value are kept together in a group with a blank key.
Inputs
- List of records
itemslistRequired - The list of records (objects) to group.
- Field to group by
fieldtextRequired - The name of the field or column whose value decides the group, for example Owner email.
- Also work out
summarytext - A figure for each group beside its count, like the total sales for each rep. It is added to each group under its name: total, average, min or max.One of:
none(Nothing more),total(The total),average(The average),min(The smallest),max(The largest). Default:none. - Of the field
of_fieldtext - The field holding the numbers, for example Amount.Only when Also work out is The total, The average, The smallest or The largest.
Outputs
One group for each distinct value of the field, in the order the values first appear.
Example output
[
{
"count": 2,
"items": [
{
"owner": "ana@example.com",
"task": "Write spec"
},
{
"owner": "ana@example.com",
"task": "Ship"
}
],
"key": "ana@example.com"
},
{
"count": 1,
"items": [
{
"owner": "ben@example.com",
"task": "Review PR"
}
],
"key": "ben@example.com"
}
]Insert item
Add an item at a specific position in a list.
Inputs
- List
itemslistRequired - The list to insert the item into.
- Position
indexnumberRequired - 0 is the first place, and -1 puts the item last.
- Item to insert
valueobjectRequired - The item to insert.
Outputs
The list with the item inserted at the position given.
Example output
[
"apples",
"bananas",
"cherries"
]Match records from two lists
Add the fields of the matching record in a second list to each record, like a spreadsheet lookup (VLOOKUP): each order gets its customer's name and plan, matched by email.
Inputs
- Records
firstlistRequired - The records to add fields to, like orders.
- Look up in
secondlistRequired - The records to take the fields from, like customers.
- Match by
fieldtextRequired - The field the records share, like Email. Letter case and spaces don't matter.
- Field in the second list
other_fieldtext - When the second list names it differently, like Customer email. Leave empty when the name is the same.
- Records without a match
keeptext - Keep records that have no match as they are, or leave them out.One of:
all(Keep them),matches(Leave them out). Default:all.
Outputs
The records, each with the matching record's fields added. A field both records have keeps the first record's value unless it is blank.
Example output
[
{
"email": "ana@example.com",
"name": "Ana",
"order": 1042,
"plan": "pro"
}
]Remove an item
Remove an item from a list wherever it appears.
Inputs
- List
itemslistRequired - The list to remove the item from.
- Item
valuetextRequired - The item to remove. Every copy of it is removed.
Outputs
The list without the item.
Example output
[
"apples",
"cherries"
]Remove duplicates
Remove repeated items from a list, or records that repeat a field, like two rows for one email address. Can also remove empty items.
Inputs
- List
itemslistRequired - The list to remove repeated items from.
- Match records by
fieldtext - For a list of records, the field that makes two records the same, like Email. The first of each is kept. Letter case and spaces don't matter. Leave empty to compare whole items.
- Empty items
remove_emptytrue/false - Keep empty items, or remove them too.Default:
false.
Outputs
The list with repeated items removed, keeping the first of each.
Example output
[
"ana@example.com",
"ben@example.com"
]Remove item by position
Remove the item at a specific position in a list.
Inputs
- List
itemslistRequired - The list to remove the item from.
- Position
indexnumberRequired - 0 is the first item, and -1 is the last.
Outputs
The list without the item at the position given.
Example output
[
"bananas",
"cherries"
]Reverse list
Reverse the order of items in a list.
Inputs
- List
itemslistRequired - The list to reverse.
Outputs
The list's items in reverse order.
Example output
[
3,
2,
1
]Shuffle list
Put the items of a list in a random order. Returns all of the items, just reordered.
Inputs
- List
itemslistRequired - The list to shuffle.
Outputs
The list's items in a random order.
Example output
[
"dee",
"ben",
"ana",
"cy"
]Sort list
Sort a list in ascending (first/smallest to last/largest) or descending (last/largest to first/smallest) order.
Inputs
- List
itemslistRequired - The list to sort. Numbers, and text that holds a number, sort by value, and dates sort by date.
- Direction
directiontext - The order to sort in.One of:
ascending,descending. Default:ascending. - Sort records by
fieldtext - For a list of records, the field to sort them by, like Amount or Created. Records without it go last.
Outputs
The list's items sorted in ascending or descending order.
Example output
[
3,
7,
42
]Split a list into batches
Split a list into smaller lists of a set size, for an app that takes so many items at a time. Loop over the batches to send each one.
Inputs
- List
itemslistRequired - The list to split.
- Items per batch
sizenumberRequired - How many items each batch holds. The last may hold fewer.At least 1.
Outputs
The batches, each a list, in the original order.
Example output
[
[
"a",
"b"
],
[
"c",
"d"
],
[
"e"
]
]Take part of list
Take a section of a list, such as the first five items or the last three.
Inputs
- List
itemslistRequired - The list to take a section of.
- Start position
startnumberRequired - This item is included. Use a negative number to count from the end (-1 is the last item).
- End position
endnumber - This item is not included. Leave blank to go through the end of the list. Use a negative number to count from the end (-1 is the last item).
Outputs
The items from the start position up to, but not including, the end position.
Example output
[
"a",
"b",
"c"
]