Open martmull opened 1 week ago
To return only updated fields of records in the Zapier update trigger, follow these steps:
Modify perform
function in triggers.utils.ts
:
perform
function.export const perform = async (z, bundle) => {
const records = await getRecords(z, bundle);
return records.map(record => {
const updatedFields = {};
for (const key in record) {
if (record[key] !== bundle.inputData.previousRecord[key]) {
updatedFields[key] = record[key];
}
}
return updatedFields;
});
};
Adjust trigger_record.ts
to use the modified perform
function:
perform
function from triggers.utils.ts
.
import { perform } from './triggers.utils';
export default { key: 'record_updated', noun: 'Record', display: { label: 'Record Updated', description: 'Triggers when a record is updated.' }, operation: { perform, // other properties } };
Client voice
We do have a trigger update record in zapier, but it returns all record field, so it is not possible to get what fields were updated
We need to find a way to send updatedFields info, probably by adding a field
updatedFields
in data inpackages/twenty-server/src/engine/api/graphql/workspace-query-runner/jobs/call-webhook-jobs.job.ts
based on args provided in the query inpackages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts
Then we should update what Zaps gets from webhooks data, today it get thedata.record
key which contains all the record -> see herepackages/twenty-zapier/src/utils/triggers/triggers.utils.ts