I have successfully retrieved the default 20 comments using the code below by specifying a single fileId parameter. However, I am interested in pulling back one hundred comments or paginating to the next set of 20 out of curiosity.
In my getComments function below, when I pass options as a parameter to Drive.Comments.list, it results in an error. But when I directly specify the fileId, it returns 20 comments.
I believe this should be an easy fix - I am still learning. Any suggestions would be greatly appreciated! Thank you!
function main() {
var fileId = getFileId();
var fileComments = getComments(fileId);
//logObj(fileComments);
//Logger.log(fileComments);//.items.length); // this always says 20
//logObj(fileComments);
logObj(fileComments.items);
}
function getFileId() {
return DocumentApp.getActiveDocument().getId();
}
function getComments(fileId) {
var options = {
'fileId': fileId,
'pageSize': 99
};
var commnts = Drive.Comments.list(fileId);
return commnts;
//Logger.log(cmnts.items.length);
}
function logObj(obj){
for (key in obj) {
var tmp = obj[key];
Logger.log(key + " = " + tmp );
}
}
function findComments(criteria){
}