简体   繁体   中英

Google APIs Triggers not identifying if its Participants or Organizer

Our Add-in has set triggers (ScriptApp.newTrigger('myFunction')) to identify on any calendar change so that we update meeting data(Title, Participants Email, Start and End date etc) back to our DB. The challenge we are facing is that the if a participant is accepting/declining/cancelling a single meeting or a series, part of series etc we receive notifications and that calendar event object does not have any object to identify its a trigger caused due to participant activity and in which case we dont need to do any action.

To explain a case -

  1. Organizer schedules a series for 4 instances and includes 2 participants.
  2. One participant cancels the meeting for last two events.
  3. We receive event that does not identify that its action from participant and end up updating. meeting as cancelled. (Ideally we should get the trigger only when Organizer cancelled).

There are objects in events to identify if its organizer or participant but these always return "self:true".

"creator":{
      "self":true,
      "email":"dev@******.com"
   },
   "organizer":{
      "self":true,
      "email":"dev@******.com"
   }, 

Is there any way we either restrict to receive notifications ONLY when organizer does any calendar update?

OR

Any way to identify from the calendar event object that this trigger is caused due to participant action?

I understand that you want to run the trigger only if the user that fires it is the event organizer. There exists a property that can help you easily manage that operation: the organizer property of the attendee object, inside the event object. That property will contain true if the attendee is an organizer for this event, and false otherwise. So you only need to include a line of code in the script to check that property and keep running only if it is equal to true .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM