GAS - 如何 delete/update 仅从一个重复事件中分离出一个事件?
GAS - how to delete/update only one event from a recurring one?
我在 fullCalendar 中显示我的 Google 日历。
现在我希望能够删除或修改 27.4 上的“重复事件”。确切地说,我想以编程方式模拟我们在日历 GUI 中单击重复事件时得到的结果。我想知道如何删除点击的事件或此事件加上所有后续事件。
如果我列出事件,那么我可以看到重复事件的 ID 是相同的
2:44:29 PM Info Number of events: 4
2:44:29 PM Info recurring event 2022-04-26 17:00 12rldkfirufdd7l20f7gi0i3tg@google.com
2:44:29 PM Info
2:44:29 PM Info zz Společný 2022-04-27 15:00 3s305giqvsgi7os1v9dupdiovs@google.com
2:44:29 PM Info
2:44:29 PM Info recurring event 2022-04-27 17:00 12rldkfirufdd7l20f7gi0i3tg@google.com
2:44:29 PM Info
2:44:29 PM Info recurring event 2022-04-28 17:00 12rldkfirufdd7l20f7gi0i3tg@google.com
见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
您可以先 list all event instances of an event 找到您感兴趣的实例的 id
或按属性查询/过滤实例,例如日期。
在 Apps 脚本中,您可以使用 Advanced Calendar Service 执行以下操作:
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);
}
})
我在 fullCalendar 中显示我的 Google 日历。
现在我希望能够删除或修改 27.4 上的“重复事件”。确切地说,我想以编程方式模拟我们在日历 GUI 中单击重复事件时得到的结果。我想知道如何删除点击的事件或此事件加上所有后续事件。
如果我列出事件,那么我可以看到重复事件的 ID 是相同的
2:44:29 PM Info Number of events: 4
2:44:29 PM Info recurring event 2022-04-26 17:00 12rldkfirufdd7l20f7gi0i3tg@google.com
2:44:29 PM Info
2:44:29 PM Info zz Společný 2022-04-27 15:00 3s305giqvsgi7os1v9dupdiovs@google.com
2:44:29 PM Info
2:44:29 PM Info recurring event 2022-04-27 17:00 12rldkfirufdd7l20f7gi0i3tg@google.com
2:44:29 PM Info
2:44:29 PM Info recurring event 2022-04-28 17:00 12rldkfirufdd7l20f7gi0i3tg@google.com
见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
您可以先 list all event instances of an event 找到您感兴趣的实例的 id
或按属性查询/过滤实例,例如日期。
在 Apps 脚本中,您可以使用 Advanced Calendar Service 执行以下操作:
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);
}
})