我正在尝试执行一些代码:
function createOrAppendFile(in_Folder, in_FileName, in_Content ) {
var fileName=in_FileName;
//var folderName=in_Folder;
var folderName="TRADEARCHIVE";
var content = in_Content;
// get list of folders with matching name
var folderList = DriveApp.getFoldersByName(folderName);
if (folderList.hasNext()) {
// found matching folder
var folder = folderList.next();
// search for files with matching name
var fileList = folder.getFilesByName(fileName);
[... snip ...]
我在appscript.json中定义了以下内容
{
"timeZone": "America/Chicago",
"dependencies": {},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"webapp": {
"executeAs": "USER_DEPLOYING",
"access": "ANYONE_ANONYMOUS"
},
"oauthScopes": [
"https://www.googleapis.com/auth/spreadsheets.readonly",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/script.scriptapp",
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/drive"
]
}
我得到了以下错误:
Nov 4, 2022, 12:28:53 AM Error Exception: You do not have permission to call DriveApp.getFoldersByName. Required permissions: (https://www.googleapis.com/auth/drive.readonly || https://www.googleapis.com/auth/drive)
at createOrAppendFile(Code:33:29)
at deleteRows(Code:173:11)
at onMyEdit(Code:390:29)
我做错了什么?任何帮助、暗示或建议都将不胜感激。
提亚
发布于 2022-11-04 07:11:55
在这个例子中,似乎对我有用的是在函数上放置一个"Open“触发器来搜索文件夹。
Deployment Event Function
Head From spreadsheet - On open createOrAppendFile
https://stackoverflow.com/questions/74312655
复制相似问题