Activators in Apps Scripts [closed]

2

I know that using Google Apps Script you can configure an activator, so that it runs every so often, but I would like to be able to configure it from the code.

They will ask themselves why, well, I made an application for my work that has a process that has to run every hour, and I have to configure this activator in each user that passes my program, so I would like it to be programmed for include it within the code and when it is installed with a user, the activator will be configured. Do you think you can?

    
asked by Fernando Tovar 20.06.2016 в 22:40
source

2 answers

1

The Google Apps Script "Script Service" has the Trigger class (trigger) . You can create a new trigger using the newTrigger (functionName) method.

It should be mentioned that it is likely that you should create a complement. Documentation on this is at link

    
answered by 21.06.2016 в 02:29
1

As Rubén said with the Trigger class you should be able to do it through code, but it is possible that it gives you problems. (mainly that sometimes does not fire)

Right now I do not know how the issue is but a while ago at least it was advisable to use manual triggers since code triggers do not go well. (I do not know if today this part has been fixed / improved)

I disagree with Rubén (sorry :) about the addon since the process of publishing an addon is quite heavy (there are quite a lot of quality filters that are totally logical but that complicate the process too much) and it does not make much sense being a script for inside a company (I understand that the script runs on the domain of the company, so it does not matter if it is public, as it should be with the addon)

By cons I would recommend another option: Have a single trigger in your script. Can you explain more or less and without details what your script should do? Do you need permissions for each user? It depends on what you had to do, maybe it would be worth having your trigger in your master script and processing the information of the users that have registered.

When I schedule scripts for my company (and I do it daily :) I always try to make users users and not owners of the script. So you have everything centralized, you facilitate the correction of bugs and control the permissions better.

If you give more details of what your script has to do refine my answer a bit more.

    
answered by 21.06.2016 в 19:50