如何替换不推荐使用的DocsList服务? [英] How can I replace the deprecated DocsList service?

查看:52
本文介绍了如何替换不推荐使用的DocsList服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自2015年4月20日起,DocsList服务服务不再起作用".我有此功能,该功能使用了docsList服务:

Since April 20, 2015 the DocsList service "service no longer functions". I have this function this function which used docsList service:

/**
 * 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服务?

How can I replace the DocsList service in this createDuplicateDocument function?

推荐答案

这是新方法:

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());
};

这篇关于如何替换不推荐使用的DocsList服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆