问题描述
我有一个用于预订房间的 GAS 网络应用.当应用程序创建事件时,它当前默认为事件的忙碌".我正在尝试将默认设置为免费".
我发现一个 GAS 论坛条目建议使用高级 Google 日历 API 来编辑透明度字段(来源:https://code.google.com/p/google-apps-script-issues/issues/detail?id=2341).p>
他们建议的脚本是
var changes = {透明度:透明"};Calendar.Events.patch(更改,cal_id,event_id);
我启用了高级 API,但由于某种原因,当函数执行时,我在 Chrome 控制台中收到未捕获的错误提示.关于这个错误来自哪里的任何想法?
环顾四周,以下似乎可行.我忘记了在向 CalendarApi 发出请求之前,您需要从 CalendarApp 返回的事件 ID 中删除@google.com".calendarId 可以设置为主要",因为用户只在自己的日历上编辑事件
var eventId= event_id.slice(0,event_id.length-11);var calendarId = '主要';Logger.log(eventId)变量更改 = {透明度:透明"};Calendar.Events.patch(changes,calendarId,eventId);
I have a GAS web app for reserving rooms. When the app creates the event, it currently defaults to "Busy" for the event. I am trying to set the default to "Free".
I found a GAS forum entry that recommends using the Advanced Google Calendar API to edit the transparency field (Source: https://code.google.com/p/google-apps-script-issues/issues/detail?id=2341).
The script they suggested was
var changes = {
transparency: "transparent"
};
Calendar.Events.patch(changes, cal_id, event_id);
I have the Advanced API enabled, but for some reason I am getting an uncaught error prompt in the Chrome console when the function executes. Any thoughts on where this error is coming from?
After looking around, the following seems to work. I forgot that you need to remove the "@google.com" from the event ID returned by CalendarApp before making a request to CalendarApi. The calendarId can be set to 'primary' since the user is only editing an event on their own calendar
var eventId= event_id.slice(0,event_id.length-11);
var calendarId = 'primary';
Logger.log(eventId)
var changes = {
transparency: "transparent"
};
Calendar.Events.patch(changes,calendarId,eventId);
这篇关于使用日历 API 更改 Google 日历活动忙/闲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!