問題描述
我有一個用于預訂房間的 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 日歷活動忙/閑的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!