Calendar Change Trigger

344 views
Skip to first unread message

Jake Green

unread,
Dec 10, 2019, 7:55:18 AM12/10/19
to google-apps-sc...@googlegroups.com
Hello dear google-specialists, my apologies for the Google translator from Russian), my questions are:

(Calendar Triggers in Apps Script \ Google Calendar events)


1. Does the API have access to the Google Calendar of tasks?
2. Is it possible to ensure the trigger is triggered by a change in Google Tasks or a Calendar tied to Google Tasks?
3. When creating a trigger, how do I select the calendar for which the trigger should work?

Dimu Designs

unread,
Dec 10, 2019, 8:54:41 AM12/10/19
to google-apps-sc...@googlegroups.com
1. Does the API have access to Google Calendar of tasks?
You can use the Tasks Advanced Service to access your tasks.

2. Is it possible to ensure the trigger is triggered by a change in Google Tasks or a Calendar tied to Google Tasks?
Unfortunately that is not possible. Calendar triggers are not tied in any way to Google Tasks (even though tasks are accessible from Google Calendar's UI). If you want to track changes to your tasks you'll need to build a custom solution. You can try using a time-based trigger to poll the Task API for state changes.

3. When creating a trigger, how do I select the calendar for which the trigger should work?
Each calendar has a unique id (formatted like an email address) that you can set when creating the trigger from your apps script dashboard. To find the calendar id, open the google calendar desktop app, hover over a calendar name listed in the sidebar menu on the left, click the icon with the 3 vertical dots and select "Settings and Sharing", scroll down until you find the calendar id listing.


 

On Tuesday, December 10, 2019 at 7:55:18 AM UTC-5, Jake Green wrote:
Hello dear google-specialists, my apologies for the Google translator from Russian), my questions are:

Calendar Change Trigger

Jake Green

unread,
Dec 10, 2019, 9:07:26 AM12/10/19
to Google Apps Script Community
Dimu Designs, I am very grateful for your reply. Very fast and helpful. This is exactly what I needed to find out! Thank you so much!

CBM Services

unread,
Dec 13, 2019, 4:43:59 PM12/13/19
to google-apps-sc...@googlegroups.com
This was good info. I was looking for that as well.

I am also having trouble when I delete a calendar event via the API, it does not send cancellation notices to the guests. Any way to force it to send cancellation notices?

From: Jake Green
Sent: ‎2019-‎12-‎10 6:07 AM
To: Google Apps Script Community
Subject: [Apps-Script] Re: Calendar Change Trigger

Dimu Designs, I am very grateful for your reply. Very fast and helpful. This is exactly what I needed to find out! Thank you so much!

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/33eb2dee-91d8-4fda-81a3-db6036e2cd7d%40googlegroups.com.

Clark Lind

unread,
Dec 17, 2019, 7:37:10 AM12/17/19
to Google Apps Script Community
The Calendar Advanced Services appears to include the "SendUpdates" option when deleting an event. Hope that is helpful!


On Friday, December 13, 2019 at 4:43:59 PM UTC-5, George wrote:
This was good info. I was looking for that as well.

I am also having trouble when I delete a calendar event via the API, it does not send cancellation notices to the guests. Any way to force it to send cancellation notices?

From: Jake Green
Sent: ‎2019-‎12-‎10 6:07 AM
To: Google Apps Script Community
Subject: [Apps-Script] Re: Calendar Change Trigger

Dimu Designs, I am very grateful for your reply. Very fast and helpful. This is exactly what I needed to find out! Thank you so much!

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

cbmserv...@gmail.com

unread,
Dec 17, 2019, 6:59:25 PM12/17/19
to google-apps-sc...@googlegroups.com

Yes I see that available in the REST API, but it does not seem to be available in the programmatical API interface which is the one I use. Hate to have to develop a REST interface just for this capability.

 

Thanks for looking at this.

 

From: google-apps-sc...@googlegroups.com <google-apps-sc...@googlegroups.com> On Behalf Of Clark Lind
Sent: December 17, 2019 4:37 AM
To: Google Apps Script Community <google-apps-sc...@googlegroups.com>
Subject: Re: [Apps-Script] Re: Calendar Change Trigger

 

The Calendar Advanced Services appears to include the "SendUpdates" option when deleting an event. Hope that is helpful!

On Friday, December 13, 2019 at 4:43:59 PM UTC-5, George wrote:

This was good info. I was looking for that as well.

I am also having trouble when I delete a calendar event via the API, it does not send cancellation notices to the guests. Any way to force it to send cancellation notices?


From: Jake Green
Sent: ‎2019-‎12-‎10 6:07 AM
To: Google Apps Script Community
Subject: [Apps-Script] Re: Calendar Change Trigger

Dimu Designs, I am very grateful for your reply. Very fast and helpful. This is exactly what I needed to find out! Thank you so much!

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

--

You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/1561b8fd-dfe6-474c-a297-cc2c17e6e493%40googlegroups.com.

Clark Lind

unread,
Dec 18, 2019, 8:05:57 AM12/18/19
to google-apps-sc...@googlegroups.com
You should be able to call advanced services from the normal Apps script interface. The syntax is just slightly different, and you just need to turn on the Calendar API (Resources --> Advanced Google Services --> Calendar API). I use some advanced services for deleting unwanted (duplicate) events on my calendar (I can see them on a different calendar, so don't need them on mine). I published this as a web app, and have it bookmarked on my browser Bookmark bar lol  (I'm not much of a coder, so I know this can be cleaned up...)
//Function to delete events from my calendar created by "XYZ Person"
//Filename: Code.gs

function doGet() {
 
var count = deleteActions();
 
var user = Session.getActiveUser().getEmail();
 
var template = HtmlService.createTemplateFromFile('index');

 
template.user = user;
 
template.count = count;
 
 
return template.evaluate();

}


function deleteActions() {
 
var calendarId = 'primary';
 
var optionalArgs = {
    timeMin
: (new Date()).toISOString(),
    showDeleted
: false,
    singleEvents
: true,
 
// sendUpdates: 'all',    //I think this is where you would add  
    maxResults
: 50,
    orderBy
: 'startTime'
   
};
 
var response = Calendar.Events.list(calendarId, optionalArgs);
 
var eventID = "";
 
var eventOwner = ""
 
var events = response.items;
 
var count = 0;
 
 
for (var i =0; i < events.length; i++) {
   
var event = events[i];
    eventID
= event.id;
    eventOwner
= event.organizer.email;
   
     
if (eventOwner == "[deleted for privacy]@group.calendar.google.com") {
        modifyevent
(eventID);
        count
= count +1;
       
}
   
}
   
return count;
}

function modifyevent(eventid){
 
var event = CalendarApp.getEventById(eventid);
 
event.deleteEvent();
}


//Small HTML file just to give me some feedback
//Filename: index.html

<!DOCTYPE html>
<html>
 
<head>
   
<base target="_top">
 
</head>
  <body>
    <h3>Hello <?= user ?>,</
h3><P>
   
<h5>I've deleted <?= count ?> Actions from your calendar.</h5>
    <p>You may have to run this a few times. (Simply refresh this page to run again).<P>
  </body>
</html>






On Tuesday, December 17, 2019 at 6:59:25 PM UTC-5, George wrote:

Yes I see that available in the REST API, but it does not seem to be available in the programmatical API interface which is the one I use. Hate to have to develop a REST interface just for this capability.

 

Thanks for looking at this.

 

From: google-apps-sc...@googlegroups.com <google-apps-sc...@googlegroups.com> On Behalf Of Clark Lind
Sent: December 17, 2019 4:37 AM
To: Google Apps Script Community <google-apps-sc...@googlegroups.com>
Subject: Re: [Apps-Script] Re: Calendar Change Trigger

 

The Calendar Advanced Services appears to include the "SendUpdates" option when deleting an event. Hope that is helpful!

On Friday, December 13, 2019 at 4:43:59 PM UTC-5, George wrote:

This was good info. I was looking for that as well.

I am also having trouble when I delete a calendar event via the API, it does not send cancellation notices to the guests. Any way to force it to send cancellation notices?


From: Jake Green
Sent: ‎2019-‎12-‎10 6:07 AM
To: Google Apps Script Community
Subject: [Apps-Script] Re: Calendar Change Trigger

Dimu Designs, I am very grateful for your reply. Very fast and helpful. This is exactly what I needed to find out! Thank you so much!

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

cbmserv...@gmail.com

unread,
Dec 18, 2019, 8:37:12 PM12/18/19
to google-apps-sc...@googlegroups.com

Thanks for the suggestion. But I do not think this works. You are suggesting adding it as an optional argument when you obtain the list of events from the calendar. That would not help as far as I can tell getting notices sent to the guests that the event is deleted.

 

I did add that when I create the event hoping that when I delete it the guests would be notified, but it does not work.

 

Here is what I do when I create the event:

 

    var cal = CalendarApp.getCalendarById(calendarId);

    var event = cal.createEvent(subject, start, end, {

       guests : notifyEmail,

       description : message,

       location : location,

       guestsCanModify :'True',

       sendInvites: 'True',

       guestsCanInviteOthers: 'True',

       sendUpdates: 'all',

       sendNotifications: true,

       reminders: {"hours" : 24}

       });

As per your example, in the deleteEvent method:

 

  var event = CalendarApp.getEventById(eventid);
 
event.deleteEvent();

Unfortunately, there is no arguments accepted to specify how it is deleted. I even tried to remove guests from the event before I delete it (hoping guests would be notified) but still no notifications are sent.

 

This one has had me baffled for a while and I suspect it is just a limitation of the API as currently defined.

 

Thanks,

  George

 

From: google-apps-sc...@googlegroups.com <google-apps-sc...@googlegroups.com> On Behalf Of Clark Lind
Sent: December 18, 2019 5:06 AM
To: Google Apps Script Community <google-apps-sc...@googlegroups.com>
Subject: Re: [Apps-Script] Re: Calendar Change Trigger

 

You should be able to call advanced services from the normal Apps script interface. The syntax is just slightly different, and you just need to turn on the Calendar API (Resources --> Advanced Google Services --> Calendar API). I use some advanced services for deleting unwanted (duplicate) events on my calendar (I can see them on a different calendar, so don't need them on mine). I published this as a web app, and have it bookmarked on my browser Bookmark bar lol  (I'm not much of a coder, so I know this can be cleaned up...)

//Function to delete events from my calendar created by "XYZ Person"
//Filename: Code.gs

function doGet() {
 
var count = deleteActions();
 
var user = Session.getActiveUser().getEmail();
 
var template = HtmlService.createTemplateFromFile('index');

 
template.user = user;
 
template.count = count;
 
 
return template.evaluate();

}


function deleteActions() {
 
var calendarId = 'primary';
 
var optionalArgs = {
    timeMin
: (new Date()).toISOString(),
    showDeleted
: false,
    singleEvents
: true,


 
// sendUpdates: all,    //I think this is where you would add  
    maxResults
: 50,

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

--

You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/27dbdca2-4e7b-424e-9465-43dc2e376a49%40googlegroups.com.

cbmserv...@gmail.com

unread,
Sep 30, 2020, 5:24:13 PM9/30/20
to google-apps-sc...@googlegroups.com

I have opened up a ticket to get this fixed. If you are impacted by this, please do a +1 on it.

 

https://issuetracker.google.com/issues/167800880

 

Thanks

Kim Nilsson

unread,
Oct 4, 2020, 7:22:50 AM10/4/20
to Google Apps Script Community
According to the issue tracker, already on the 14th September a googler forwarded your report for further internal investigation.
Reply all
Reply to author
Forward
0 new messages