简体   繁体   中英

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.

Trigger1 can be set by Add Trigger button in addon homepage. Similarly it can be removed by Remove Trigger button. Similarly remove button is also working, but working on my Addon Appscript project.

Testing:

  1. Project deployed as test add on.
  2. Addon installed.
  3. I create a new spreadsheet named Test SS . It has my addon already installed.
  4. I click Add Trigger button.

Results: Trigger1 is created but it is created on my Everyday Addon Appscript project. It is not created on the new spreadsheet- Test SS .

What did I got wrong? Should not the trigger sit on Test SS spreadsheet's project? If 100's of user install my addon then 100 of Trigger will sit on my Addon project?

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM