仅查看用户的onOpen触发器 [英] onOpen trigger for view-only users

查看:75
本文介绍了仅查看用户的onOpen触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅当用户有权编辑打开电子表格或文档时,Google Apps脚本中的内置onOpen触发器才会运行。我正在开发一个电子表格,其中只有开发人员具有编辑权限,而所有其他用户必须具有仅查看权限。

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.

如何创建仅查看用户打开电子表格以及具有编辑权限的用户时将触发的onOpen触发器?

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

推荐答案

您不能,因为它不受支持。嵌入在Google表格,文档,表单中的Google Apps脚本以及作为附件的Google Apps脚本仅适用于编辑器。

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.

另一种方法是将其发布为网络应用程序,因此,查看者可以直接打开而不是打开工作表,或者从工作表单元格中的链接打开webapp(在另一个选项卡上,而不是工作表内部)。

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

这篇关于仅查看用户的onOpen触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆