Philippe Neveux
Philippe Neveux

Reputation: 13

Time-driven Trigger : Possibility to set a trigger up every minute for a deploy script app / gmail add-on?

I'm developing a google script app in order to deploy a gmail add-on.

I try to set a trigger up every minute, which executes a function, with the following code :

ScriptApp.newTrigger(FUNCTION_TRIGGERED)
              .timeBased()
              .everyMinutes(1)
              .create(); 

The problem is, when I'm running the function in the google developer hub, it works, the time trigger is created.

But when I deploy the script as a gmail add-on from the manifest file and I want to create the trigger on a button click, an error appears telling me that the trigger range between two occurrences must be at least every hour.

And the weirdest thing is when I set the trigger up every hour, I can change it to every minute in the trigger options, in the g suite developer hub. Why would I could do that ?

I wish to know if it's possible to create a trigger within a gmail add-on which triggered the same function every minute. Or, is it definitely impossible ?

Upvotes: 1

Views: 315

Answers (1)

Wicket
Wicket

Reputation: 38150

Setting a time-driven trigger programmatically to run every minute through an add-on is impossible

From https://developers.google.com/apps-script/guides/triggers/installable#time-driven_triggers

(Note that an add-on can use a time-driven trigger once per hour at most.)

While only Google could say why this is this way, we could assume that as an add-on could be installed by many users (potentially millions of users) setting this limitation is a way to prevent over loading the Internet and to prevent abuses.

I never tried to edit the trigger settings from a trigger created by add-on from another developer, so I can't tell you for sure if you was able to edit the trigger settings only because you are the Apps Script project owner or if this something that could be done by any add-on user.

Upvotes: 2

Related Questions