Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I replace the deprecated DocsList service? [duplicate]

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?

like image 483
craftApprentice Avatar asked Mar 17 '23 07:03

craftApprentice


1 Answers

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());
};
like image 171
Alan Wells Avatar answered Apr 02 '23 11:04

Alan Wells