Home > Blockchain >  How can I add an event trigger that fires when a contact is edited, created or deleted in my Google
How can I add an event trigger that fires when a contact is edited, created or deleted in my Google

Time:10-01

I am making a Google Sheets Spreadsheet that needs to have all of my contacts from my account, up to date with any changes that are made. Outputting to the Spreadsheet is the easy part, but I can't find resources in the Google API Reference nor in Stack Overflow (except for this post from 5 years ago) referencing such an 'onContactUpdated()' trigger.

This leads me to believe that such a trigger doesn't actually exist, which I think is peculiar, considering the Calendar API has an already integrated trigger that comes with the base Apps Script experience:

ScriptApp.newTrigger('functionName').forUserCalendar('userEmail').onEventUpdated().create();

Did I just miss it? Does it exist? If so, how can I create one?

And in case one doesn't exist, what other solution can you guys recommend to me? The contact list is already 400 contacts long, and it is expected to keep growing over time. I don't know of a way in which I could just keep polling in a time-based manner that would keep the list up-to-date without getting ever so close to exceeding the 90min total daily runtime quota.

Any solutions would be greatly appreciated. Thanks in advance, Felipe Santini.

CodePudding user response:

Short Answer:

No, there is no event object for Contacts API or People API.

Long Answer:

You still need to poll your contacts list for any changes using a time-based trigger. Your polling frequency depends on your need and the limitation of the daily runtime quota. To save runtime, you could poll changes only for specific fields instead of checking everything.

  • Related