目标:通过 Google 日历添加与会者添加到现场创建的实时事件
上下文:正在创建现场事件(左)+ 日历添加(右)
代码片段:
current_user = e.calendar.calendarId;
event_id = e.calendar.id;
var calendar = CalendarApp.getCalendarById(current_user);
var event = calendar.getEventById(event_id);
但是,当我打开一个事件,并且 current_user
和 event_id
有值时,event
似乎为 null
,因为从技术上讲该事件尚未“创建”。如果它已经创建,那么一个简单的 event.addGuest()
就可以工作
是否可以在创建实时事件时对其进行自定义?我发现的每个示例都只更新已创建的事件。
编辑:忘记发布我正在使用的范围。 appsscript.json 的片段如下
{
....,
"oauthScopes": [
"https://www.googleapis.com/auth/calendar.addons.current.event.read",
"https://www.googleapis.com/auth/calendar.addons.current.event.write",
"https://www.googleapis.com/auth/calendar.addons.execute",
"https://www.googleapis.com/auth/script.external_request",
"https://www.google.com/calendar/feeds"
],
"addOns": {
"common": {
...
}
},
"calendar": {
"currentEventAccess": "READ_WRITE",
...
}
}
}
最佳答案
将代码更改为:
if (!e.calendar.capabilities.canAddAttendees) {
return;
}
CardService.newCalendarEventActionResponseBuilder()
.addAttendees(["<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="badfc2dbd7cad6df8bfadfc2dbd7cad6df94d9d5d7" rel="noreferrer noopener nofollow">[email protected]</a>", "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5f3a273e322f333a6d1f3a273e322f333a713c3032" rel="noreferrer noopener nofollow">[email protected]</a>"])
.build();
关于google-apps-script - 有没有办法通过 Google Apps 脚本修改实时日历事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67323077/