function listComments() {
// setting the sheetId to the current sheet I am using
var sheetId = '(mySpreadsheetId)';
var arg = {
pageSize: 100
}
Drive.Comments.list
var comments = Drive.Comments.list(sheetId, pageSize=arg);
var cList = [];
// getting the active spreadsheet and current sheet to extract comments from
var spreadsheet = SpreadsheetApp.openById(sheetId).getSheets()[10];
Logger.log(comments)
// Get list of comments
if (comments.items && comments.items.length > 0) {
for (var i = 0; i < comments.items.length; i++) {
var comment = comments.items[i];
// add comment and highlight to array's first element
cList.unshift([comment.content]);
}
// logging the sheet to check if I am using the correct sheet
Logger.log(spreadsheet.getName())
Logger.log(spreadsheet.getSheetId())
Logger.log(cList)
// getting the spreadsheet to add the comments to
var commentsheet = SpreadsheetApp.openById(sheetId).getSheets()[11]
Logger.log(commentsheet.getName())
commentsheet.getRange("A1:A" + cList.length).setValues(cList);
}
}
I am getting the lastest 20 comments, which is the default for the list function in the Comments api. I have been using the comments documentation (https://developers.google.com/drive/api/v3/reference/comments/list), but I have still been unsuccessful in getting the comments I need. Any help is appreciated.