具有可安装日历事件触发器的工作区附加组件停止与新部署一起使用

Workspace Add-on with installable calendar event trigger stops working with new deployment

我们的工作区插件使用可安装的日历事件触发器。

只要有日历更新事件就会触发触发器。

ScriptApp.newTrigger('calendarTrigger').forUserCalendar(calendarId).onEventUpdated().create();

在我们部署新版本的附加组件之前,这一切正常。

部署后,可安装触发器仍然存在,但与以前的部署版本相关联。

任何日历事件都将被忽略,触发器将无所事事。

我们可以编写我们的附加组件以删除触发器并重新添加它,但这需要我们的附加组件由用户打开。

ScriptApp.deleteTrigger(tr);
ScriptApp.newTrigger('calendarTrigger').forUserCalendar(calendarId).onEventUpdated().create();

问题是在这次手动干预之前忽略了日历事件(这可能在一段时间内不会发生)。

当我们部署新版本的应用程序时,我们应该如何进行触发器更新?

确保在每次新部署时更新 GCP 平台中的工作区插件,以做到这一点:

  1. 访问 GCP
  2. 商城 > Google 商城 SDK > 应用程序配置
  3. 在使用 Apps 脚本部署 ID 进行部署(第一项)中更新部署 ID。

部署 ID 可在 Apps 脚本项目 > 部署(蓝色按钮,右上角)> 管理部署 > 选择活动部署(在左侧)中找到,并显示其部署 ID。

另请注意,如果您创建脚本的新版本,那么我建议您在部署时单击当前版本,然后单击钢笔(在顶部)然后“添加新版本” .这样一来,一个部署就有一个新版本,而不是多个部署都有不同的活动版本。

更新:预期行为:

Google 在 Issue Tracker 提供了更新,说明这是按预期工作的:

This is intended behavior. Workspace add-on triggers installed using older deployments will get disabled if the add-on is updated with a new deployment.

In order to update a Workspace add-on without disabling the current deployment triggers, edit a versioned deployment instead of creating a new one.

The team will look into improving the UI in order to avoid potential confusion around this.

问题:

不久前在 Issue Tracker 中报告了相同的行为,尽管在这种情况下指的是时间驱动的触发器:

这似乎发生在所有通过 Workspace 附加组件安装的触发器上:一旦 Workspace 附加组件更新为新部署,附加到旧部署的触发器就会停止执行 .

解决方法:

虽然此时尚不清楚这是否是预期的行为,但可能的解决方法(如 ) for updating a Workspace add-on without disabling the current deployment triggers is to edit a versioned deployment instead of creating a new one 所述。