Home > Blockchain >  GAS - how to delete/update only one event from a recurring one?
GAS - how to delete/update only one event from a recurring one?

Time:04-29

I display my Google Calendar in fullCalendar.

fullCalendar shows Google Calendar

Now I would like to be able to delete or modify the "recurring event" on 27.4. To be exact I want to programatically simulate what we get when we click recurring event in Calendar GUI. I want to know how to delete the event thas clicked or this event plus all following events.

enter image description here

If I list events then I can see that the IDs of recurring event are the same

2:44:29 PM  Info    Number of events: 4
2:44:29 PM  Info    recurring event 2022-04-26 17:00 [email protected]
2:44:29 PM  Info    
2:44:29 PM  Info    zz Společný 2022-04-27 15:00 [email protected]
2:44:29 PM  Info    
2:44:29 PM  Info    recurring event 2022-04-27 17:00 [email protected]
2:44:29 PM  Info    
2:44:29 PM  Info    recurring event 2022-04-28 17:00 [email protected]

CodePudding user response:

See Modifying or deleting instances

To modify a single instance (creating an exception), client applications must first retrieve the instance and then update it by sending an authorized PUT request to the instance edit URL with updated data in the body. The URL is of the form: https://www.googleapis.com/calendar/v3/calendars/calendarId/events/instanceId

You could first list all event instances of an event to find theid of the instance you are interested in or query / filter the instances by properties like e.g. the date.

In Apps Script, you can do it with the Advanced Calendar Service as following:

function myFunction() {
  var eventId = "XXXXX";
  var instances = Calendar.Events.instances("primary", eventId).items;
  instances.forEach(function(event){
    console.log(event.start.dateTime);
    if(event.start.dateTime == "2022-06-03T19:00:00 02:00"){
      event.summary = "new Title";
      Calendar.Events.update(event, "primary", event.id);
    }
  })
  • Related