How to Aggregate Array Line Items after Looping Iterations
Contributed by: Troy Tessalone - Automation Ace - Certified Zapier Expert
About
Looping an array of line items is one thing in a Zap, but aggregating an array of line items is another in a Zap.
Arrays
Think of line items in an array like the items in an ecommerce order. (1 Order can have 1+ Items)
Use Case
You want to perform some action(s) on each line item in an array, then continue the Zap steps with the aggregated line items. (e.g. very basic example - adjusting the format of each item to be UPPERCASE)
Apps
These native Zap apps by Zapier count as 0 Tasks in Zap Runs.
Resources
Steps
- Trigger: [APP] - [EVENT]
- UP TO YOU!
- Action: Formatter > Text > Default Value
- Use a UNIX Timestamp to get a unique ID for use in following Zap Storage steps
- Help: https://zapier.com/help/create/customize/insert-the-time-your-zap-runs-into-a-field
- Action: Looping - Create Loop from Line Items
- Handles arrays of line items
- Action: Formatter > Numbers > Perform Math Operation
- Used so the loop iterations process sequentially in order
- See the help article above.
- Action: Delay - For
- Delay For (minutes)
- Map the output from the previous Formatter step
- Action: [APP] - [EVENT]
- UP TO YOU!
- Example: Formatter > Text > Uppercase
- Action: Storage - Push Value onto List
- Adds Items to the Array
- Action: Filter
- Loop Iteration is Last = true
- Action: Storage - Get Multiple Values
- Use the lookup key from Step 2
- Will return an array with items that were processed during the loop iterations
- Action: [APP] - [EVENT]
- UP TO YOU!
- e.g. Add Items to an Order
- Action: Storage - Remove Value
- Remove the Storage Value as it’s no longer needed since the Zap Run has completed
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/35a43d70-cdbd-433e-88b0-effe0b13fe05.png)
Steps - Details
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/abc3e1d1-833a-4dff-9dd7-c9733fec84b2.png)
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/9d54342e-3a8a-40ed-a165-8ff2428ccac1.png)
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/d4fd946e-0743-4f93-9cda-d46b0c9a8f92.png)
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/e080e12b-2d97-44d9-a7fd-2f0c7e5449c2.png)
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/c2d49ae7-c21d-4f1a-b3bf-2bfa7f3f1338.png)
TIP
If you want to flatten the array line items, like a digest, then use this Zap action: Storage - Get List Values
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/43ec5cd3-f9c6-409e-aaf3-2a2a4f2775f2.png)