How to delete/update only one event from a recurring one?

123 views
Skip to first unread message

Radek Šimčík

unread,
Apr 28, 2022, 8:53:13 AM4/28/22
to Google Apps Script Community
Hi all

I want to know how to edit/update recurring event. How to "simulate" dialog box from Calendar GUI

"Delete recurring event"
- this event
- this and following events
- all events

I created StackOverflow question for that one https://stackoverflow.com/q/72043967/250422

Thank you
Radek

Clark Lind

unread,
May 2, 2022, 3:55:15 PM5/2/22
to Google Apps Script Community
This took a while to figure out, but I got some of it working. Basically, there is no modifying of existing eventRecurrences and
instead of modifying it, you replace it by creating a new one with the options you want. This example is probably the hardest,
removing a single occurrence from the series. From here, the rest is easy. 

function removeSingleEvent() {
  var recurringEventName = "Monday Meeting";
  var startDateTime = new Date('May 2, 2022 13:30:00 EDT');
  var startDate = new Date('May 2, 2022');
  var endDateTime = new Date('May 2, 2022 14:30:00 EDT');
  var dateOfExclusion = new Date('May 23, 2022');
  var events = CalendarApp.getEventsForDay(startDate, {title: recurringEventName}); 
  var eventSeries = CalendarApp.getEventSeriesById(events[0].getId());
  var recurrence = CalendarApp.newRecurrence()
    .addWeeklyRule().times(52)
    .addDateExclusion(dateOfExclusion);

  eventSeries.setRecurrence(recurrence, startDateTime, endDateTime);
}

Reply all
Reply to author
Forward
0 new messages