javascript - Google 脚本应用程序-变量内的变量错误

标签 javascript google-apps-script

用于搜索的 Google 驱动器脚本 - 我无法添加搜索词的变量。一旦我添加它,我就会继续收到错误 - 也许我做错了?

最终我想要一个带有搜索框和搜索术语的按钮的网络应用程序。随着所有者变量...

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]);

}

}

最佳答案

您只需在正确的位置添加引号即可:

var searchterm ="'print';
var searchFor ="title contains " + searchterm;
var owneris =" and 'youremail@yourdomain.com' in owners";

请务必更改您的 mail@yourdomain.com

关于javascript - Google 脚本应用程序-变量内的变量错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41641556/

相关文章:

javascript - 迭代构造函数链

mysql - 如何查询我的数据库并将其输出到 Google 表格,以便有人可以编辑此数据,然后将其反射(reflect)回 MySQL?

javascript - Google Apps 脚本 - 将横向参数添加到 PDF 电子邮件附件

google-apps-script - 我应该如何在许多不同的 Google 电子表格上重用函数?

javascript - 使用 SVG DOM 创建比例变换

javascript - 如何在 React Redux 中获取状态的先前值

javascript - 组件服务未注入(inject)到 Jasmine 中的测试中

javascript - angularjs:使用 $compile 时指令中的范围问题

javascript - 构建 HTML 时属性 ID 无效

javascript - 使用 Google Apps 脚本在不通知用户的情况下共享云端硬盘文档