How to stop duplicate Triggers from running your Zap

  • 12 May 2021
  • 7 replies
  • 3254 views
How to stop duplicate Triggers from running your Zap
Userlevel 7
Badge +2
  • Community Manager
  • 20 replies

Mod Edit: 03-18-2022

Hey folks, it’s Tim here from Premier Support with another Workflow for you!

Triggers should only trigger once per new record, but sometimes it’s possible due to a bug or a missing feature for a Trigger to fire more than once for new records, and that may not be what you want.

If you run into a problem like this, please reach out to support so that we can investigate further, but if it can’t be fixed right away, there are a few workarounds that we can use to create supplemental “deduplication”, the process of keeping track of which records we’ve seen before.

Google Sheets & Airtable

One way to do this is to set up a Google Sheet or Airtable with one column called id where you can keep track of the unique id’s of the records that Trigger the Zap.

In your Zap, right after the Trigger:

  • (Optional) If the Triggers fire very close together, you may need to add a Delay After Queue Step of 1 minute to allow time for the other steps to process.
  • After the optional Delay, add a Google Sheets/Airtable Find or Create Row/Record. Step with the id from the Trigger record.
  • After the Find or Create Row/Record Step, add a Filter.
  • The Find or Create Row/Record Step will return a value called Zap Data Was Found
  • Set the Filter to only continue the Zap if the Zap Data Was Found field is (boolean) is false, meaning that we haven’t seen this record before.

Code Step with Storage

Setting up a Sheet or Airtable isn’t ideal as it creates an external part to the Zap that you’d need to keep track of. Instead, we can use Storage by Zapier in a similar way by setting up some custom code to use Storage in this way. I’ve provided the code below, and it doesn’t need to be modified at all - just copied and pasted into the Code Step.

In case you haven’t used Storage by Zapier before, it works by allowing us to store up to 500 pieces of information per “Account”. You can have as many storage “Accounts” as you like by generating a unique secret/key for each one. To make sure we’re using something unique, we’ll use generated UUIDs as shown below.

The setup in the Zap is similar, starting right after the Trigger:

  • (Optional) If the Triggers fire very close together, you may need to add a Delay After Queue Step of 1 minute to allow time for the other steps to process.
  • After the optional Delay, add a Code by Zapier: Run Javascript Step.
  • In the Code Step, create two input fields: storageKey and dedupeKey
  • Each time you set one of these Steps, visit this site: https://www.uuidgenerator.net/ and copy the unique UUID that is generated and paste it into the storageKey field.
  • It’s important to use a different key for each Zap that you use this workflow in because it will use the maximum capacity of a single Storage account to remember all the record IDs that have Triggered.

  • Map the unique record ID from the Trigger into the dedupeKey field

  • Finally, copy the code from here and paste it into the Code field

  • Your Code Step should look like something like this:

  • The Code Step will output a value called previouslySeenValue:
  •  

    Set the Filter to only continue the Zap if previouslySeenValue field is (boolean) is false, meaning that we haven’t seen this record before.

The Code Step with Storage can store up to 500 unique record IDs and will cycle out the oldest keys when that limit is exceeded in favour of the newest ones.

And that’s it! After setting this up, you should be able to add deduplication to your Zaps that are Triggering more often than expected for each record.

Let me know if you have any questions about this!

Please note

We aren't always able to help with Code questions via Zapier Support because not everyone on the Support Team is familiar with Javascript and Python, and supporting custom code is technically outside of our scope of support. A great place to ask if we can't support you directly is here in our community or on Stack Overflow by tagging your question "Zapier": https://stackoverflow.com/questions/tagged/zapier


7 replies

@TimS Hello! Your article is very useful, thank you very much.

 But it seems i found a little mistake. Using Google sheets or airtable we need to delete the last added row (which triggered the zap), and after filtration we need to add this row back in Google/Airtable using our trigger outputs. Otherwise i’m receiving a “true” value when searching the row with the same unique ID (or email in my case). Am I right or not? 

Userlevel 7
Badge +2

Hi @Asker ! Thanks for taking a look and trying this out :)

It sounds like the workflow you’re describing is when you’re Triggering from an Airtable or Google Sheet and then Find or Creating the row in the same Airtable/Google Sheet, is that right? If so, to clarify, you’ll always want to use a separate Airtable/Google Sheet to Find/Create for the purposes of this workflow.

You’re right that if we tried to do this in the same Trigger spreadsheet, it wouldn’t ever pass the filter because it would always be found. By using a separate spreadsheet, we can prevent this from happening without needing to micromanage by deleting / recreating any rows in the Trigger spreadsheet.

Let me know if that makes sense!

Hi Tim, I currently have my Zapier integrated to Smartsheet, do you have any feedback on how I can prevent these duplicates from appearing ? 

What would be the Action Event on Storage by Zapier? 

Userlevel 4
Badge +1

Just adding a quick update that the Filter steps needs the condition:

only continue if > Previously Seen Value > (boolean) is false

Hi Tim, I currently have my Zapier integrated to Smartsheet, do you have any feedback on how I can prevent these duplicates from appearing ? 

Hey Jazzata1, have you figured it out?

Badge

Hi Tim,

 

Im trying to get this to work by following your code step, I feel like I have it set up correctly but its still triggering twice (I have raised it with the application provider who the trigger is with however their support isn't great).

 

Heres some screenshots of how I have the Zap set up and the Zap runs history.

 

Have I done something wrong?

 

Regards

 

 

Reply