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.
API response contains an array like this:
[
{ id: 1, title: 'AWS', time: '2021-12-03T11:41:13.615Z', modTime: '2021-12-03T11:41:13.615Z' },
{ id: 2, title: 'GCP', time: '2021-12-03T11:41:13.615Z', modTime: '2021-12-03T11:46:13.615Z' },
]
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.
To make an update trigger, use an API endpoint that lists all items, both new and updated, or alternately an endpoint that lists only updated items. Zapier needs a composite id field that changes whenever the item is updated (ideally z.hash('md5', item.id + item.updated_at)), so subsequent updates aren’t be filtered out by Zapier’s deduper.
For that, I created a new key updated_at
and copied the value of modTime
key. But this trigger is working only for new records and not for any update in existing record. Am I missing something ? I can make id every time new like this { id: rec.id + ':' + rec.modTime ... }
but it will run for new records as well which I don't want.
Here is my code:
// import statements
const listData = async (z) => {
const records = await getTaskList(z);
return records.map((rec) => ({
...rec,
updated_at: rec.modTime
}));
};
export default {
display: {
description: 'Triggers when a task will be updated.',
label: 'Task Updated',
},
key: 'task_updated',
noun: 'Updated Task',
operation: {
outputFields: outFields,
perform: listData,
sample: getSampleData(),
},
};