I'm working on the following script, which is supposed to look at the current document, grab its comments, make a copy, and copy the comments to the new document. However, I seem stuck. I'm not actually sure how to grab and copy the comments. ".getComments" and ".setComments" seems to fail. What am I missing?
function onOpen() {
// Add a menu with some items, some separators, and a sub-menu.
DocumentApp.getUi().createMenu('Copy Comments')
.addItem('Copy with comments', 'copyDocument')
.addToUi();
}
function copyDocument(e) {
var app = DocumentApp.getActiveDocument();
var origId = app.getId();
var origName = app.getName();
var origFile = DocsList.getFileById(origId);
//Set the scope
var scope="https://www.googleapis.com/auth/drive";
// GET the comments from the original Document
var listUrl = "https://www.googleapis.com/drive/v2/files/"
+ origId
+ "/comments";
var originalComments = listUrl.getComments();
// Make a copy of the Document and store the ID
var newFileId = origFile.makeCopy('Copy of ' + origName).getId();
// Set the URL to POST to
var newUrl = "https://www.googleapis.com/drive/v2/files/"
+ newFileId
+ "/comments";
// Write the comments to the new Document
var insert = originalComments.setComments(newURL);
}