如何允许onEdit()访问Google云端硬盘文件和文件夹 [英] How to allow onEdit() to access Google Drive files and folders

查看:60
本文介绍了如何允许onEdit()访问Google云端硬盘文件和文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Google Apps脚本功能 push_permissions(),该功能可以从电子表格中读取权限并将其应用于Google云端硬盘文件和文件夹.手动运行时,该功能按预期工作,但是我希望每次在一定范围内进行编辑时都自动触发此功能.所以我做了这个 onEdit()函数:

  function onEdit(e){如果(e.range.columnStart == 10& e.range.rowStart> 2& e.value.includes('@ gmail.com'))push_permissions();}; 

每当触发 onEdit()时,都会引发此错误:

 异常:您无权调用SpreadsheetApp.openByUrl.所需权限:https://www.googleapis.com/auth/spreadsheets在onEdit(Permissions:2:27) 

任何使这项工作可行的方法吗?

解决方案

onEdit 具有简单的Google Apps脚本触发器类型.

要获得对示波器的完全访问权限,您必须安装EDIT事件触发器.

请为此手动管理触发器./p>

I have a Google Apps Script function, push_permissions(), that reads permissions from a Spreadsheet and applies them to Google Drive files and folders. The function works as expected when manually run, but I wanted to automatically trigger this function every time edits are made on a certain range. So I made this onEdit() function:

function onEdit(e) {
  if (e.range.columnStart == 10 && e.range.rowStart > 2 && e.value.includes('@gmail.com')) push_permissions();
};

Whenever onEdit() is triggered, it throws this error:

Exception: You do not have permission to call SpreadsheetApp.openByUrl. Required permissions: https://www.googleapis.com/auth/spreadsheets
at onEdit(Permissions:2:27)

Any way to make this work?

解决方案

onEdit has the simple type of Google Apps Script Triggers.

For getting full access of scopes you have to install the trigger for EDIT event.

Please check Managing triggers manually for that.

这篇关于如何允许onEdit()访问Google云端硬盘文件和文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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