0

I've been trying to get some custom validations and access checks done in spreadsheets, based on the groups the users belong to.

As far as I know, the following trigger bound to a container(a spreadsheet) should have the rights of the user accessing the spreadsheet:

function onEdit(event) {
    var groups = GroupsApp.getGroups();
    Logger.log(groups);
}

Still, it runs into an error: "Execution failed: You do not have permission to call getGroups". The same function called from a standalone script file(in theory the same access) will see the groups of the user.

My questions are:

  • Am I doing something wrong?
  • If not, is there a way to access the groups of a user from a spreadsheet event?

Probably not relevant, but using Windows 8 and Chrome 30.0.1599.101 m.

4

2 回答 2

0

Zig Mandel 的回答是正确的,因为像 onEdit 这样的简单事件无法调用需要授权的方法,但是您试图获取用户组,这将是一个问题,因为可安装的触发器在脚本作者的授权下运行(实际上设置触发器的人通常是脚本作者),这意味着不是用户组,而是您的组......

所以我担心你试图做的事情是不可能的,因为这与电子表格脚本中的隐私规则相矛盾。(阅读Zig在他的回答中提到的文档)

访问用户组信息的唯一方法是使用菜单中的直接函数调用或使用请求授权的按钮。那里没有自动化......

于 2013-11-12T19:55:14.767 回答
0

如果您要阅读 onEdit 文档,它会说您不能调用需要身份验证的方法。使用不同的名称安装触发器,而不是使用简单触发器。

于 2013-11-12T13:46:23.193 回答