DriveApp folder.getUrl()已更改或损坏?

时间:2014-02-26 23:00:51

标签: google-apps-script

以下函数返回url的空值 function test(){

    var folderiter = DriveApp.getFolders();
          while (folderiter.hasNext()) {
          var  folder = folderiter.next();
          Logger.log(folder.getName()+" url:"+folder.getUrl())


  }

}

1 个答案:

答案 0 :(得分:0)

正如DavidF所说,它已经破碎了,但这是一个解决方法:

function myFunction() {

  var folderiter = DriveApp.getFolders();
  while (folderiter.hasNext()) {
            var  folder = folderiter.next()
            var  folderId = folder.getId()//new line added to your code
            //DocsList.getFolderById(folderId).getURL() works to get url as variable
            var  url = DocsList.getFolderById(folderId).getUrl()
            Logger.log(folder.getName()+" url:"+url)//modified to use variable instead of method


  }

}

我使用自己的文件夹和文件对此进行了测试,但我无法确认它是否适用于每种文件/文件夹类型。但是,如果它对你有帮助,你能接受答案吗?