javascript - 更改 Google 日历中事件的颜色

标签 javascript google-apps-script google-calendar-api

我正在尝试使用 Google Apps 脚本中的高级日历服务来更改日历中特定事件的 colorId。

到目前为止,我已经能够列出获取 事件以及我喜欢的事件。所以我有事件的 ID。

function getSpecificEvent(){
  var calendarId = 'primary';
  var eventId = '7h2tbvns2oo4r5gku6ghjfjclk';
  var calEvent = Calendar.Events.get(calendarId, eventId);
  Logger.log(calEvent);
}

这就是我在编辑 colorID 时尝试的方法,我使用 patch :

function setEventColor(){
  var calendarId = 'primary';
  var eventId = '7h2tbvns2oo4r5gku6ghjfjclk';
   Calendar.Events.patch(calendarId, eventId).colorId('11');
}

但是我得到这个错误: enter image description here

本例中的第 33 行是这一行:

   Calendar.Events.patch(calendarId, eventId).colorId

最佳答案

这有点棘手......但我发现它是如何工作的:

function ChangeEventColor(){
  var calendarId = 'primary';
  var eventId = 'omv°°°°°°°°°°8jbs'
  var event = Calendar.Events.get(calendarId, eventId)
  Logger.log('current color = '+event.colorId)
  event.colorId = 11
  Calendar.Events.patch(event,calendarId,eventId);
  Logger.log('new color = '+event.colorId)
}

This post (匿名)很有帮助

关于javascript - 更改 Google 日历中事件的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35482104/

相关文章:

javascript - Google Calendar API v3 推送通知不尊重 timeMax 或 timeMin

javascript - 如何检索 Google 日历事件的扩展属性?

powershell - 如何通过 Google Calendar API 检索相关日历事件?

javascript - 自定义管道未正确导入

javascript - 在 React Native 中,为什么 const 类型用于例如 : const { navigate } = this. props.navigation;?

javascript - 使用谷歌脚本自动将 CSV 输出到谷歌表格

javascript - 无法运行 window.URL.createObjectURL(blob) 来显示 .png 文件

javascript - 使用 jquery 放置可拖动对象

javascript - 添加新行后不能 "refresh"filamentgroup tablesaw 响应表

javascript - 格式化从电子表格中读取的数字