我需要将此 Doclist 代码迁移到 Drivapp,但不能

I need to migrate this Doclist code to Drivapp, but couldn't

我刚刚尝试用 Driveapp 替换 Doclist 以使用参数 (num,num) 执行文件搜索,但 returns 出现错误:invalid method getFiles(num,num).

function b(e) {
  var app = UiApp.getActiveApplication();

  var resultado = ""
  var urlBase = "https://docs.google.com/a/escuelasanpedro.com/file/d/";
  var doc = DocsList.getFolderById("0B8p4BFVjx9pDZXFIYUQzSFZqeFE").getFiles(0,500)
  var idDoc =""
  var nombre =""
  for ( var i = 1; i < doc.length;i++) { 
       if (e.parameter.userName == doc[i].getName().substring(0,doc[i].getName().indexOf("."))) { 
          idDoc = doc[i].getId()
          nombre = e.parameter.userName
          resultado = urlBase + idDoc ;
          }
       }  

我尝试了以下代码,但收到消息 "function 'getname' cannot be found in iterator objetct"

function b(e) {
  var app = UiApp.getActiveApplication();
//serverhandler, proceso real

  var resultado = ""
  var urlBase = "https://docs.google.com/a/escuelasanpedro.com/file/d/";

  var doc = DriveApp.getFolderById("0B8p4BFVjx9pDZXFIYUQzSFZqeFE").getFiles()
  var idDoc =""
  var nombre =""

 while (doc.hasNext()) {
   var file = doc.next();
       if (e.parameter.userName == doc.getName().substring(0,doc.getName().indexOf("."))) { 
          idDoc = doc.getId()
          nombre = e.parameter.userName
          resultado = urlBase + idDoc ;
       }
 }

您几乎明白了...您的 doc 变量是迭代器,名为 file 的新变量是实际文件,但您没有使用它。

像这样更新:

 while (doc.hasNext()) { 
 var file = doc.next();
 if (e.parameter.userName == file.getName().substring(0,file.getName().indexOf("."))) { idDoc = file.getId()