onOpen trigger for view-only users

放肆的年华 提交于 2019-12-24 05:26:06

问题


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:


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



来源:https://stackoverflow.com/questions/32661868/onopen-trigger-for-view-only-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!