Question

A trigger which should run on update of existing record is not working

  • 30 December 2021
  • 3 replies
  • 25 views

I am trying to create a trigger (Poll based) in Zapier app/integration which should run the zap when an existing item will be updated.

Now, as per the doc, if an item will contain id and updated_at key then it should work if same record will be updated with last modified timestamp field. A detailed question is already asked on StackOverflow with Zapier tag but I think community can help me more easily rather than SO.

I understand that Zapier deduper identify the changes by checking the difference in item’s id. Now what I want from trigger -

  1. It should run only when an existing record will be modified (modTime is a key which will be updated on each modification)
  2. It should not run if a new record will be created.
  3. It should show the id field value as original one for any action with which this trigger will be used. 
  4. I can create new id on modification of any record like { id: rec.id + ':' + rec.modTime ... } but it does not work as per Point 3 because we are changing output fields

Am I missing something or is there any other way to do this ? Let me know if you have any other question in it.


3 replies

Userlevel 7
Badge +10

Hi @d33p 

Zapier uses the id field for deduplication. you can store the original id in a new key before modifying it. 

First, i would suggest declaring an empty array to push your modified objects into. Some sudo code below to get you started

let finalOutput = [];

After you’ve received your polling results (which should either be sorted by last updated time or should only returned items that were recently updated). You will need to loop through each object declaring a new id. 

 

FOR EACH object IN results array
object.original_id = object.id
object.id = object.id + objecet.modTime;

Since, it shouldn’t run if the item is new and not updated then i would add a conditional statement that checks if created time != modTime

IF object.createdTime != object.modTime 
  finalOutput.push(object)
END IF

END LOOP

Return finalOutput

Hi @d33p 

Zapier uses the id field for deduplication. you can store the original id in a new key before modifying it. 

First, i would suggest declaring an empty array to push your modified objects into. Some sudo code below to get you started

let finalOutput = [];

After you’ve received your polling results (which should either be sorted by last updated time or should only returned items that were recently updated). You will need to loop through each object declaring a new id. 

 

FOR EACH object IN results array
object.original_id = object.id
object.id = object.id + objecet.modTime;

Since, it shouldn’t run if the item is new and not updated then i would add a conditional statement that checks if created time != modTime

IF object.createdTime != object.modTime 
  finalOutput.push(object)
END IF

END LOOP

Return finalOutput

Are not we exposing new key originalId and modifying actual id to let zapier know about new records. Because same finalOutput will be used as input to configured action when someone will use this trigger.

Is is possible to configure different set of keys for zapier and output fields ?

Userlevel 7
Badge +10

@d33p 

I am not sure i fully understand your question. You can modify the results from your polling however you see fit. 

Zapier will trigger for every object with a unique never seen before id in the array of objects you return. 

Reply