简体   繁体   English

Appscript插件触发器设置在我的插件项目中,而不是用户的电子表格的appscript项目

[英]Appscript addon triggers are set inside my addon project, instead of user's spreadsheet's appscript project

I am creating an appscript addon named Everyday Addon which create trigger named Trigger1 which runs every day.我正在创建一个名为Everyday Addon的 appscript 插件,它创建名为Trigger1的触发器,它每天运行。

Trigger1 can be set by Add Trigger button in addon homepage. Trigger1可以通过插件主页中的Add Trigger按钮来设置。 Similarly it can be removed by Remove Trigger button.同样,它可以通过Remove Trigger按钮删除。 Similarly remove button is also working, but working on my Addon Appscript project.同样,删除按钮也在工作,但在我的 Addon Appscript 项目上工作。

Testing:测试:

  1. Project deployed as test add on.作为测试插件部署的项目。
  2. Addon installed.已安装插件。
  3. I create a new spreadsheet named Test SS .我创建了一个名为Test SS的新电子表格。 It has my addon already installed.它已经安装了我的插件。
  4. I click Add Trigger button.我单击Add Trigger按钮。

Results: Trigger1 is created but it is created on my Everyday Addon Appscript project.结果: Trigger1已创建,但它是在我的Everyday Addon Appscript 项目中创建的。 It is not created on the new spreadsheet- Test SS .它不是在新的电子表格Test SS上创建的。

What did I got wrong?我做错了什么? Should not the trigger sit on Test SS spreadsheet's project?触发器不应该放在Test SS电子表格的项目上吗? If 100's of user install my addon then 100 of Trigger will sit on my Addon project?如果 100 的用户安装我的插件,那么 100 的触发器将坐在我的插件项目中?

This is intended behaviour!这是预期的行为!

The trigger that you create programmatically will be attached to the add-on rather than the target Spreadsheet - this is because the function you intend to run on trigger is in the add-on project file, not the target Sheet's bound script.您以编程方式创建的触发器将附加到加载项而不是目标电子表格 - 这是因为您打算在触发器上运行的 function 位于加载项项目文件中,而不是目标工作表的绑定脚本中。

That being said - this is per-user behaviour.话虽如此 - 这是每个用户的行为。 You won't have hundreds of triggers all bound to your script project after publishing because each time a trigger is created by a user it will be tied to their account and not yours.发布后,您不会将数百个触发器全部绑定到您的脚本项目,因为每次用户创建触发器时,它将绑定到他们的帐户,而不是您的帐户。

Remember: the Apps Script Quotas limit triggers to 20 per user per script , so each user can have up to 20 triggers installed via your add-on before they will not be able to install any more.请记住: Apps 脚本配额将触发器限制为每个用户每个脚本 20 个,因此每个用户最多可以通过您的插件安装 20 个触发器,然后他们将无法再安装。

Further reading: as per the documentation on testing editor add-ons :进一步阅读:根据测试编辑器插件的文档:

Installable triggers aren't supported when testing.测试时不支持可安装触发器 Functionality that depends on installable triggers are not testable.依赖于可安装触发器的功能是不可测试的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检查谷歌 appscript 项目的现有触发器? - How to check existing triggers on google appscript project? 电子表格中的 AppScript 和 WebApp 中的 AppScript - AppScript in SpreadSheet and AppScript in WebApp 单个项目的多个 AppScript 聊天机器人 - Multiple AppScript chatbots for a single project Google Sheets AddOn - 通过服务帐户集成 AppScript 和 BigQuery - Google Sheets AddOn - AppScript & BigQuery Integration via Service Account 我们如何为 appscript 驱动插件自定义 LoadIndicator? - How can we customize LoadIndicator for appscript drive addon? AppScript oauth 范围和链接的 gcp 项目范围之间有什么关系? - What is the relationship between AppScript oauth scopes and linked gcp project's scopes? 如何使用 AppScript 项目在 GoogleSpreadsheet 中设置单元格背景颜色 - How to set Cell Background Color in GoogleSpreadsheet Using AppScript Project Google AppScript的Sheet.getName()返回对象,而不是字符串 - Google AppScript's Sheet.getName() returns object instead of string 插件中的公式权限错误 - getActiveUser - Formula's permission error inside an Addon - getActiveUser Google AppScript 项目中的 TypeScript 类顺序 - TypeScript classes order in Google AppScript Project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM