According to Google app script time-trigger documentation https://developers.google.com/apps-script/guides/triggers/installable#limitations,
Time-driven triggers cannot run more frequently than once per hour. How can I use app script to write an add-on that process large amount of data?
If I run a trigger, it will only allow me to trigger once. I can't chain the triggers so it can continuously run.
You cannot do so using triggers because they would run at most once per hour in the context of an add on.
What you can do is to initiate such processing client-side while possibly showing progress on a sidebar. The client js in the sidebar can chain server calls.Of course being all client-side means the user must have opened the file and if they close the browser tab or navigate away, the chain calls will stop. That can be handled by alerting the user and making them aware that a "sync" happens and sometimes takes a while. Currently there is no other way to handle this unless your client call and time trigger call another server which does the processing, like appengine or gce.
Related
I manage a large Google spreadsheet where I use apps script to automatically sort and format form responses by using time-based triggers.
This sheet and many more like it are owned by one google account, not the ones who manage the individual sheets.
I have noticed that the performance of my scripts is very inconsistent over time. One minute they execute in 10-30 seconds, then they keep timing out for 2 hours, just to then suddenly work again. This happens regardless of what the actual script is and whether it is run by a trigger or manually.
I know that one of the limitations of Apps Script is 30 simultaneous executions per user.
So my question is: Does that limitation apply to the owner of the apps script project or the one who set up the triggers and runs the scripts?
Because if it's the former, then maybe the reason for the performance issues is that there are dozens of sheets fighting over those 30 execution slots?
Quota call is attributed to the user running the script. The "user running the script"/the effective user is different in different circumstances. In case of
Instance
Whose quota?
Script editor "Run"
User at the keyboard
Menu "Run"/Button click
User at the keyboard
Simple triggers
User at the keyboard
Installable triggers
User who installed the trigger(regardless of who is at the keyboard)ref
Custom function
User at the keyboard
Webapp(execute as me)
User who installed the trigger(regardless of who is at the keyboard)
Webapp(execute as user accessing)
User at the keyboardref
Quota calls are not attributed to the owner unless the owner satisfies any of the above criteria.
Reference:
User identity/permissions
I have a Google Script running every 5 minutes. It works except randomly there are sudden crashes and the script/trigger won't survive that. So, for many different reasons, the script stops running after some weeks of continuing runtime. At this point, I would need a notification.
How can I get a notification if a function (script) hasn't run in say 2 hours? Doesn't matter what the technique/notification is, but probably email would be great for the notification. I don't think the solution can be in the script code itself, because the script randomly (every few weeks) crashes at Google's side and there's nothing I can do about that.
Google Apps Script installable triggers automatically set an email notification. You could edit when it should be sent (i.e. send immediately) and you could add more notifications. NOTE: This can only be done manually.
The above will work for "normal" failures but it there is a service outage or other platforms failures the notification might not be sent.
One option is to log the executions somewhere then set a second trigger to check that the first trigger ran every time that it should do it as expected. NOTE: The failure that prevented that the first trigger run might also prevent that his second trigger run i.e. a service outage so you might want to set other monitoring measures accordingly the the severity/priority of this failure and your project budget.
I wrote a custom GAS that reads some emails and manipulates them. It uses the time based trigger to run. I want to know if there is a way to "deploy" a specified version of this where the time based trigger still runs, but I can still work on new code changes in the apps script editor (running it manually) and then deploy that new version (that runs by time triggered) when it is ready?
You might want to look into add-ons:
https://developers.google.com/apps-script/add-ons/
I have a script in a google spreadsheet which changes the activated cell.
I you have selected A1 for example the script activates A3.
If you run it again it selects A5 and so on.
This is what it should do.
Now I want the script to be run timer-based in foreground.
I installed a trigger for that but the script only runs in background when started by the trigger.
Background is that I have a PC running, showing an overview list.
This List has now grown to be longer than the Monitor can display.
So I want the PC to automatically scroll through the document let's say one step every minute.
I could do it with an iteration but that would stop the script after the execution time out of 6 minutes while the script should run about 8h a day.
Any ideas how to solve this problem?
Don't use GAS for this. It runs server side with it's non-adjustable constraints.
Use something like an automator which will simulate keyboard commands. You can script it client side, by sending the "down" button to scroll through your list. Check "Autoit" for windows.
not possible using triggers as they can only perform server side work.
the only possible way with apps script is to open a sidebar from onOpen and use setInterval to keep calling your server function.
this also consumes less time quotas as most of the time is spent from clientside than relying on the 6minute server limitto keep updating state.
I have a web app that creates a process that can take well above 6 min to complete. I have decided to chunk it out using timed triggers and scriptDB to track execution process.
I have my web app shared within our organization, to execute as the user accessing it.
Are the script triggers created as the user, or as the script-owner in this case?
If your script is set to execute as the user accesing it, then the triggers are created under the user's account and not the owner of the script.