2个时间触发器-Google应用脚本 [英] 2 Time triggers - Google app scripts

查看:101
本文介绍了2个时间触发器-Google应用脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在线查看了Google应用程序脚本可安装的触发文档( https://developers.google. com/apps-script/support ),其中一个示例说明了2如何创建2个时间触发器.

i looked at the google app script installable trigger docs online (https://developers.google.com/apps-script/support) , and one of the examples shows how 2 create 2 time triggers.

function createTimeDrivenTriggers() {
  // Trigger every 6 hours.
  ScriptApp.newTrigger('myFunction')
      .timeBased()
      .everyHours(6)
      .create();

  // Trigger every Monday at 09:00.
  ScriptApp.newTrigger('myFunction')
      .timeBased()
      .onWeekDay(ScriptApp.WeekDay.MONDAY)
      .atHour(9)
      .create();
}

我的代码:

function createTimeDrivenTriggers() {
  // Trigger every 1 hours.
  ScriptApp.newTrigger('MainFunctionDaily')
      .timeBased()
      .everyHours(1)
      .create();

  // Trigger every Friday at 13:00.
  ScriptApp.newTrigger('MainFunctionWeekly')
      .timeBased()
      .onWeekDay(ScriptApp.WeekDay.FRIDAY)
      .atHour(13)
      .create();
}

但是,当我尝试创建触发器时,出现错误:

However when i try to create the triggers, i get an error:

此插件在此文档中为此Google用户帐户创建了太多基于时间的触发器

请告知

推荐答案

更新:附件的文档已移动.在这种情况下,以下提到的限制的新位置是 https://developers.google.com/gsuite/add-ons/concepts/editor-triggers

UPDATE: The documentation for add-ons was moved. In this case the new location of the below referred restriction is https://developers.google.com/gsuite/add-ons/concepts/editor-triggers


在Google Apps脚本附加组件上,无法通过代表同一用户运行的函数在同一文档上创建两个相同类型的触发器.


On Google Apps Scripts add-ons it's not possible to create two triggers of the same type on the same document by a function ran on behalf of the same user.

来自 https://developers.google.com/apps-脚本/指南/触发器/installable#limitations (重点是我):

限制
附加组件中的可安装触发器有几个限制:

Limitations
Several limitations apply to installable triggers in add-ons:

每个用户,每个用户,每个插件只能每种类型只有一个触发器 文档.例如,在给定的电子表格中,给定的用户只能 有一个编辑触发器,尽管用户也可以提交表单 触发或同一电子表格中的时间驱动触发.

Each add-on can only have one trigger of each type, per user, per document. For instance, in a given spreadsheet, a given user can only have one edit trigger, although the user could also have a form-submit trigger or a time-driven trigger in the same spreadsheet.

替代方案是

  • 使用不同的帐户创建每个触发器.
  • 为每个必需的触发器创建多个附加组件
  • 使用常规脚本而不是附加组件.

这篇关于2个时间触发器-Google应用脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆