Limit
The Limit step shortens a list. You say how many entries to keep, and it returns that many from the start.
Use it to stop work getting out of hand. The top ten results rather than every match. A handful of records while you are still testing. A batch small enough to stay inside an APIβs rate limit.
Slicing inside a field? You can take the first N items of a list or shorten a string directly inside field tokens using Data Transformation:
- First N list items:
{{ 2.items | keep_first:3 }} - First / last item only:
{{ 2.items | first }}or{{ 2.items | last }} - Shorten string length:
{{ 2.description | limit:100 }}
Use the Limit canvas step when passing a sliced list into a downstream Loop or multi-step branch.
Setting it up
Choose the list
Pick it from the lists the field offers, which come from the steps before this one. Choose Enter it myself to type a reference such as {{ 3.results }} or paste a JSON list instead.
Say how many to keep
A whole number. Zero is allowed and returns an empty list.
Choose which end to take them from
The beginning of the list, or the end.
Order decides which ones survive
Limit has no opinion about which entries are the most important. It takes them from whichever end you chose, and the entries keep the order they were already in.
So sort first if βthe top tenβ means anything more than βany tenβ. A Sort ahead of Limit turns it into the highest-value ten.
Taking from the end is the shortcut when the list is already in the order you want and you need its tail. The ten most recent entries, in a list sorted oldest first.
A list shorter than the limit comes back whole
Asking for ten when the list has four returns all four. It is not an error and nothing is padded.
What it passes on
The shortened list:
{{ 5.$full_result }}The step also counts the items for you: {{ 5.resultCount }} is how many it passed on, and {{ 5.results }} is the list as the data panel offers it.
Examples to copy
The three biggest orders
- A Sort step first: field
total, type Number, descending - Then Limit: 3, from the beginning
Without the Sort, this is three arbitrary orders.
A safe test run
While building a workflow that emails every customer, a Limit of 2 in front of the email step keeps a mistake from reaching everyone.
Remember to remove it before the workflow goes live.
Limits
Limit works on lists of up to 100,000 items. A longer list is refused with a message naming both numbers, rather than being cut short. Split it first.
Whatβs Next?
- Sort β decide which entries end up first
- Filter β keep entries by a test rather than by count
- Loops & Iteration β do something with each entry that survives