Installable time-driven triggers in Google Sheets Add-on - multiple users & spreadsheets

61 views
Skip to first unread message

Chris Tales

unread,
Jun 15, 2020, 7:02:02 PM6/15/20
to Google Apps Script Community
Hi there!

I'm looking for answers to a couple of questions as mentioned in the following stack - many of you might already be following GAS tags, though hopefully I can get more insight by increasing the reach. Hopefully that doesn't go against any unwritten rules here!


I'm working on an addon that needs to update spreadsheets in user specified intervals (from once an hour to once a year) - is there a smart, proven way to handle that with automatic trigger check/installation and multiple users between multiple spreadsheets?
  
From what I understand the triggers are installed individually per user - can anyone reveal the mystery behind how the time-driven triggers for add-ons work in the following cases?
  
1. The check whether triggers are installed doesn't 'see' if it's been been installed by other users and it can't manipulate it (eg. delete someone else's trigger when no longer needed). Any ideas on how to cope with that? Having 50 users with installed hourly triggers is not ideal.
  
2. Multiple spreadsheets with the addon installed: will the trigger run the called function in all of them simultaneously or do they require individual triggers per sheet? Dry testing seems to indicate that the triggers need to be set up individually per sheet, though would be great if someone could confirm their experience from an add-on that's already online.
  
In order to control a potential chaos I'm considering adding a 'last updated' property to scheduled update instances and have the triggered function compare the time difference between that and current time, but then it's still going back to having that function run every hour multiplied by the amount of users.
  
I hope the explanation is clear enough - please feel free to ask for clarification if need be. Any help would be greatly appreciated! 

Stack link: https://stackoverflow.com/questions/62398061/installable-time-driven-triggers-in-google-sheets-add-on-multiple-users-spre


Faustino Rodriguez

unread,
Jun 16, 2020, 12:10:59 PM6/16/20
to Google Apps Script Community
My comments below as far as I have learnt
1. There is no way to cope with that. The trigger is per user per spreadsheet and one user won't see other user's trigger
2. Each user has to install the trigger on each spreadsheet

On 'last updated', if it is a document property, then each user trigger in the specific document will see that property, so the script could skip or run the function as required
Reply all
Reply to author
Forward
0 new messages