Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return only updated fields of records in zapier update trigger #6071

Open
martmull opened this issue Jun 28, 2024 · 2 comments
Open

Return only updated fields of records in zapier update trigger #6071

martmull opened this issue Jun 28, 2024 · 2 comments
Assignees

Comments

@martmull
Copy link
Contributor

martmull commented Jun 28, 2024

User voice

In Zappier I could set up only trigger that on any change it notifies me. But I want to configure on specific events or tasks.

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 in packages/twenty-server/src/engine/api/graphql/workspace-query-runner/jobs/call-webhook-jobs.job.ts based on args provided in the query in packages/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 the data.record key which contains all the record -> see here packages/twenty-zapier/src/utils/triggers/triggers.utils.ts

@martmull martmull self-assigned this Jun 28, 2024
Copy link

greptile-apps bot commented Jun 28, 2024

To return only updated fields of records in the Zapier update trigger, follow these steps:

  1. Modify perform function in triggers.utils.ts:

    • Locate the perform function.
    • Add logic to filter and return only the updated fields of the records.
    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;
        });
    };
  2. Adjust trigger_record.ts to use the modified perform function:

    • Ensure the trigger uses the updated 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
        }
    };

About Greptile

This response provides a starting point for your research, not a precise solution.

Help us improve! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

Edit Issue Bot Settings

@martmull
Copy link
Contributor Author

this ticket don't take care of the Zapier integration update. It will be handled here #7812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🔖 Planned
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants