onOpen trigger for view-only users

2019-07-18 20:51发布

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条回答
等我变得足够好
2楼-- · 2019-07-18 21:33

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.**

查看更多
登录 后发表回答