![](/img/trans.png)
[英]Google Apps Script error "Exception: You do not have permission to access the requested document. (line 14)."
[英]Google Spreadsheet script, file access in Drive, “You do not have permission to call …”
我有一个工作表,我需要在其中获取位于我的 Google 驱动器中的文件的 ID。 我写了以下脚本:
function get_id_pdf() {
var nom='INV432-altaïr-Famille XXX-XXX Marie-03-2016.pdf';
var files = DriveApp.getFilesByName("'"+nom+"'");
while (files.hasNext()) {
var file = files.next();
var name = file.getName();
var type = file.getMimeType();
var url = file.getUrl();
var id = file.getId();
// Logger.log(file.getId());
return file.getId();
}
}
如果我在脚本编辑器(使用run
按钮)中执行它,它运行良好(我得到日志的 id)。 但是,如果我从 Google-Sheet 的单元格(在单元格中: =get_id_pdf()
)调用脚本, =get_id_pdf()
收到错误消息:
“您无权调用 getFilesByName ”(见图)
我当然拥有访问此文件的所有权限(它在我自己的驱动器中,并且该文件是我创建的)。
有人有想法吗?
问候。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.