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
anddedupeKey
- 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 thededupeKey
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