Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 使用多个参数搜索Google Drive_Google Apps Script_Google Sheets_Google Drive Api - Fatal编程技术网

Google apps script 使用多个参数搜索Google Drive

Google apps script 使用多个参数搜索Google Drive,google-apps-script,google-sheets,google-drive-api,Google Apps Script,Google Sheets,Google Drive Api,我正在尝试使用nameconstains或fullTextContains查找名为“Speed”的电子表格文件(通过mimeType) 如果我只使用fullTextContains或name contains或任何其他方法,但如果我将其与方法mimeType结合使用,我将获得所有电子表格文件,而不仅仅是特定的匹配项 我当前的脚本: function SearchFiles() { var searchFor = { 'name contains': "Vel", 'mimeType': "s

我正在尝试使用
nameconstains
fullTextContains
查找名为“Speed”的电子表格文件(通过
mimeType

如果我只使用
fullTextContains
name contains
或任何其他方法,但如果我将其与方法
mimeType
结合使用,我将获得所有电子表格文件,而不仅仅是特定的匹配项

我当前的脚本:

function SearchFiles() {
  var searchFor = { 'name contains': "Vel", 'mimeType': "spreadsheet" };
  var names = [];
  var fileIds = [];
  var files = DriveApp.searchFiles(searchFor);
  while (files.hasNext()) {
    var file = files.next();
    var fileId = file.getId();
    fileIds.push(fileId);
    var name = file.getName();
    names.push(name);
  ...

您得到的是隐式对象->字符串转换,因为该方法采用的是
字符串
参数,而不是
对象
。请考虑建立一个符合.< /p>的有效和有效的查询字符串。 例如:

var qs = "name contains 'Vel' and mimeType='" + MimeType.GOOGLE_SHEETS + "'";
var results = DriveApp.searchFiles(qs);

非常感谢你!!这正是我想要的=d抱歉,对于不便的tehhowch,它可以用第三个参数和这部分#+“'”#来完成它的工作原理?谢谢你的帮助=D@LuisAvl您需要查看有关组合条件的预期语法以及如何输入值的链接。您还需要了解JavaScript字符串连接(在我的回答中使用
+
)。对于这种基础教育,您必须阅读文档。