自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());
}
如何替换此DocsList
函数中的createDuplicateDocument
服务?
答案 0 :(得分:5)
以下是新方式:
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());
};