且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何允许onEdit()访问Google云端硬盘文件和文件夹

更新时间:2023-02-14 14:23:53

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.