How to remove duplicates from an array of line items

  • 11 January 2022
  • 2 replies
How to remove duplicates from an array of line items
Userlevel 7
Badge +14

📌  We do our best to ensure that the code in these articles works as advertised, but please be aware that Zapier Support does not officially help with code steps due to their advanced nature. Feel free to comment on the article or ask in the Zapier Community, where we have code-savvy folks (including the author of this post).

Q: Ever wanted to remove duplicates from an array of line items?
A: Use a Code app as a Zap step:

Code step configuration using JavaScript

NOTE: Map your line items array to the right side value for the “Set” Input Data variable in place of “A,B,C,C,B,A”.

Copy the Code

let Set = inputData.Set.split(","); // creates array by splitting Input Data variable at commas

let Distinct = []; // empty array to store the unique values

Set.forEach((i) => {
if (!Distinct.includes(i)) {

output = [{Set, Distinct}];



Code step results WITH removing duplicate values from an array of line items

Contribution by Troy Tessalone

Troy is a Certified Zapier Expert who automates workflows with no-code and low-code apps to help clients save time and make money.

2 replies

Userlevel 1

Great script, super helpful! 🙏 Minor nitpick which prevents compilation: there is a missing `{` in the last line of your code. 

Userlevel 7
Badge +14