尝试编辑受保护的工作表时,脚本触发的onEdit会遇到权限错误 [英] Script triggered onEdit runs into permissions error when trying to edit protected sheet

查看:86
本文介绍了尝试编辑受保护的工作表时,脚本触发的onEdit会遇到权限错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对电子表格的Google脚本有问题。我通过资源菜单安装了 onEdit 脚本。该脚本将某些单元格从不受保护的工作表复制到受保护的工作表。当我登录到自己的帐户(我是电子表格的所有者)时,该脚本可以正常工作,但是从无法访问受保护工作表的协作者帐户运行时,该脚本会遇到权限错误。 该脚本是否应该以我(帐户所有者)的身份运行,并且不会遇到权限问题?
同一电子表格中另一个在

onFormSubmit上运行的脚本能够在协作者提交表单时编辑受保护的工作表,即使他无权访问受保护的工作表。这表明问题不在于权限本身,而是问题特定于onEdit触发器,对吗?

I have a problem with a Google script for a spreadsheet. I have a script installed onEdit through the Resources menu. The script copies some cells from an unprotected sheet to a protected sheet. The script works fine when I'm logged in to my account (I'm the owner of the spreadsheet), but runs into permission errors when run from a collaborator's account who has no access to the protected sheet. Shouldn't the script run as me (the account owner) and not run into permission issues? Another script in the same spreadsheet that runs onFormSubmit is able to edit a protected sheet when a collaborator submits a form, even though he has no access to the protected sheet. This suggests the problem is not with permissions per se, but that the problem is specific to the onEdit trigger, right?

推荐答案

这是预期的行为。 onEdit触发器是三个简单触发器之一。

This is expected behavior. The onEdit trigger is one of three 'simple triggers'.

来自文档
这些简单的触发器是为响应Google Spreadsheets中的操作而运行的,它们以活动用户身份运行。例如,如果Bob打开Spreadsheet,则onOpen函数将以Bob的身份运行,而不管是谁将脚本添加到了因此,简单触发器在允许执行的操作中受到限制:

From the docs: "These simple triggers run in response to actions in Google Spreadsheets, and they run as the active user. For example, if Bob opens the Spreadsheet, then the onOpen function runs as Bob, irrespective of who added the script to the Spreadsheet. For this reason, the simple triggers are restricted in what they are permitted to do:


  • 在打开电子表格时,它们无法执行

  • 他们无法确定当前用户。

  • 他们无法以该
    用户身份访问任何需要身份验证的服务。例如,Google翻译服务是匿名的,可以通过简单的触发器访问
    ; Google日历,Gmail和网站
    不是匿名的,并且简单的触发器无法访问那些
    服务。 / li>
  • 他们只能修改当前的电子表格。其他
    电子表格是禁止的。

这篇关于尝试编辑受保护的工作表时,脚本触发的onEdit会遇到权限错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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