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());
}
How can I replace the DocsList
service in this createDuplicateDocument
function?
Here is the new way:
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());
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With