3

我正在开发一个谷歌日历插件

我希望能够在插件中修改事件字段(例如标题)。我有一个函数在被触发时运行eventOpenTrigger。根据文档,我们只能addAttendeessetConferenceData。我测试了这些功能,它们在现有和新事件中都运行良好。是否有任何适当的方法来修改其他事件字段?

我发现了一个“肮脏的技巧”来使用CalendarApp API修改现有事件的事件标题:

function onCalendarEventOpen(e) {
  var calendar = CalendarApp.getCalendarById(e.calendar.calendarId);
  var event = calendar.getEventById(e.calendar.id);
  if (!event) {
    // This is a new event still being created.
    return createSimpleTextCard('A new event! Am I invited?');
  }
  event.setTitle('Modified title') // imagine doing this after a button click
  return createSimpleTextCard('Modified title');
}

这个技巧有一些缺点:

  1. 我们当前正在编辑的事件页面的 ui 没有相应地刷新;我们必须关闭/打开事件才能看到更改。另外,如果用户对修改后的字段进行任何更改,它会保留他的版本。有没有办法强制“刷新”这些字段,以便用户可以看到事件的最新版本?
  2. 它不适用于新事件(在查询 API 时我们没有有效的 ID),这对于我正在开发的插件来说非常烦人。

有人有更好的解决方案吗?我错过了什么吗?拥有一个setTitle与.addAttendeesCalendarEventActionResponseBuilder

4

0 回答 0