How to Aggregate Array Line Items after Looping Iterations

  • 27 February 2024
  • 0 replies
  • 62 views

Userlevel 7
Badge +14

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

  1. Trigger: [APP] - [EVENT]
    1. UP TO YOU!
  2. Action: Formatter > Text > Default Value
    1. Use a UNIX Timestamp to get a unique ID for use in following Zap Storage steps
    2. Help: https://zapier.com/help/create/customize/insert-the-time-your-zap-runs-into-a-field
  3. Action: Looping - Create Loop from Line Items
    1. Handles arrays of line items
  4. Action: Formatter > Numbers > Perform Math Operation
    1. Used so the loop iterations process sequentially in order
    2. See the help article above.
  5. Action: Delay - For
    1. Delay For (minutes)
    2. Map the output from the previous Formatter step
  6. Action: [APP] - [EVENT]
    1. UP TO YOU!
    2. Example: Formatter > Text > Uppercase
  7. Action: Storage - Push Value onto List
    1. Adds Items to the Array
  8. Action: Filter
    1. Loop Iteration is Last = true
  9. Action: Storage - Get Multiple Values
    1. Use the lookup key from Step 2
    2. Will return an array with items that were processed during the loop iterations
  10. Action: [APP] - [EVENT]
    1. UP TO YOU!
    2. e.g. Add Items to an Order
  11. Action: Storage - Remove Value
    1. Remove the Storage Value as it’s no longer needed since the Zap Run has completed

 

 

Steps - Details

 

 

 

 

 

TIP

If you want to flatten the array line items, like a digest, then use this Zap action: Storage - Get List Values

 


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.