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 如何替换不推荐使用的DocsList服务?_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 如何替换不推荐使用的DocsList服务?

Google apps script 如何替换不推荐使用的DocsList服务?,google-apps-script,google-sheets,Google Apps Script,Google Sheets,自2015年4月20日起,DocsList服务“服务不再运行”。我有此功能此功能使用docsList服务: /** * Duplicates a Google Apps doc * * @return a new document with a given name from the orignal **/ function createDuplicateDocument(sourceId, name) { var source = DocsList.getFileById(s

自2015年4月20日起,DocsList服务“服务不再运行”。我有此功能此功能使用docsList服务:

/**
 * Duplicates a Google Apps doc
 *
 * @return a new document with a given name from the orignal
 **/

function createDuplicateDocument(sourceId, name) {
    var source = DocsList.getFileById(sourceId);
    var newFile = source.makeCopy(name);

  var targetFolder = DocsList.getFolderById(TARGET_FOLDER);
    newFile.addToFolder(targetFolder);
    return DocumentApp.openById(newFile.getId());
}
如何在此
createDuplicateDocument
功能中替换
DocsList
服务?

以下是新方法:

function createDuplicateDocument(sourceId, name) {
  //var source = DocsList.getFileById(sourceId);
  var source = DriveApp.getFileById(sourceId);

  var newFile = source.makeCopy(name);

  //var targetFolder = DocsList.getFolderById(TARGET_FOLDER);
  var targetFolder = DriveApp.getFolderById(TARGET_FOLDER);

  //newFile.addToFolder(targetFolder);
  targetFolder.addFile(newFile);

  return DocumentApp.openById(newFile.getId());
};

@ZigMandel-我想你是指这篇评论的OP。。。你肯定不希望桑迪那样做!是的,对不起!我讨厌手机应用:)