1
votes

I have a template document with a bound script that does some basic field validation. In addition to a menu item, I create a time-based trigger in onOpen(e) to run the validation function every minute. All of this works perfectly when I open the template document (I've granted the permission to access the document when prompted).

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

When I create a copy of this template document, the time-based trigger doesn't run for other users. From documentation and here I read that the installed trigger would run with my credentials which is ok. But I do not understand why the trigger won't run in the copied document for another user with EDIT rights (or prompt for rights)?

Is this approach feasible? Add-ons can only run once per hour so I cannot use that and there is no onEdit() trigger for documents. Does the onOpen() have to also be an installed trigger for this to work?

1

1 Answers

1
votes

Your time-driven trigger is an installable trigger, but I assume that your onOpen(e) trigger isn't

So yes, if your onOpen(e) function is meant to install a time-driven trigger - this is a request that requires authorization and consequently cannot be carried out from within a simple onOpen(e) trigger as specified here.

Thus, unfortunately you would need to add manually an installable onOpen trigger to each copy of the template.