如何让其他人看到应用脚本为日历事件添加的描述

问题描述 投票:0回答:1

我有一个 Google 应用程序脚本,它可以执行很多操作,并最终为 Google 日历事件的描述设置一些内容。这对我有用,我可以在 calendar.google.com 上看到新的描述,但其他客人看不到。

代码的相关部分如下所示:

const events = CalendarApp.getDefaultCalendar().getEvents(today, endDate)
const event = events.find(e => e.getTitle() === "My Special Title")
event.setDescription(newDescr)

如果我从网页手动设置描述,则会收到以下提示:

您想向现有的 Google 日历访客发送更新电子邮件吗?

无论我选择什么,其他人都可以看到更新的描述,所以我不认为这是日历/事件可见性的问题。

拥有该活动的日历不是我的,我是具有编辑权限的客人之一。

有什么想法吗?

google-apps-script google-calendar-api
1个回答
0
投票

解决方案:

使用

getDefaultCalendar()
仅对运行脚本的用户的日历的事件进行更改,这就是事件所有者和来宾无法看到所做更改的原因。

相反,只要事件所有者的日历与运行具有编辑权限的脚本的用户共享,就可以使用

getCalendarById()

代码.gs

function myFunction() {

  const events = CalendarApp.getCalendarById('CalendarID').getEvents(today, endDate);
  const event = events.find(e => e.getTitle() === "My Special Title");
  event.setDescription(newDescr);

}

参考资料:

getCalendarById()

© www.soinside.com 2019 - 2024. All rights reserved.