Google脚本app-变量可变错误

时间:2017-01-13 18:53:27

标签: javascript google-apps-script

Google搜索驱动脚本 - 我无法为searchterm添加变量。一旦我添加它我继续得到错误 - 也许我错了吗?

最终我想要一个带有搜索框的网络应用程序,搜索条件的按钮。随着owneris变量......

function SearchFiles() {
//Please enter your search term in the place of Letter
var searchterm ='print';
var searchFor ='title contains "searchterm"';
var owneris ='and "youremail@yourdomain.com" in Owners';
var names =[];
var fileIds=[];
var files = DriveApp.searchFiles(searchFor + owneris);
while (files.hasNext()) {
  var file = files.next();
  var fileId = file.getId();// To get FileId of the file
 fileIds.push(fileId);
 var name = file.getName();
 names.push(name);

}

for (var i=0;i<names.length;i++){
 Logger.log(names[i]);
Logger.log("https://drive.google.com/uc?export=download&id=" + fileIds[i]);

}

}

1 个答案:

答案 0 :(得分:2)

您只需要在正确的位置添加引号,它应该有效:

if (i < 0)
{
    i = arrayLength ;
}

请务必更改youremail@yourdomain.com