3
votes

The built-in onOpen trigger in Google Apps Script only runs when a user with permission to edit opens a spreadsheet or document. I am developing a spreadsheet where only developers have edit privileges and all other users must have view-only privileges.

How do I create an onOpen trigger that fires when view-only users open my spreadsheet as well as those with edit privileges?

1

1 Answers

4
votes

You can't, because it's not supported. Google Apps Script, embedded in either Google Sheets, Docs, Forms, and as an add-on, runs only for editors.

The alternative is to Publish as a webapp, so the viewers open that instead of the sheet directly, or open the webapp (on another tab, not inside the sheet) from a link in a sheet cell.

From the "Restrictions" section of trigger documentation on triggers - both simple and installable:

They do not run if a file is opened in read-only (view or comment) mode.**