我正在尝试将带有标签的邮件内容(从google工作表中读取)复制到一个主题为文档名称的文档中。如果已经存在单据,则需要在同一单据中添加邮件正文;如果不存在,则需要创建一张以主题为单据名称的单据。我正在使用的脚本的一部分是:
function searchdrive(x) {
var iterator = DriveApp.searchFiles(x);
if(iterator.hasnext()) {
var docid = iterator.next().getId();
return docid;
Logger.log(docid);
}
var doc = DocumentApp.create(x);
docid = doc.getId();
return docid;
}如果文档还不存在,iterator.hasnext()应该返回false,但它却抛出一个错误作为无效参数。
我该如何解决这个问题呢?
https://stackoverflow.com/questions/38429214
复制相似问题