0
votes

I am writing google docs with several people at the same time and in order to track who has to do what, I am using comments.

Each part of the document is then assigned to someone and he has to update the status of his part in the comment (in a structured format).

Thanks to a Macro in VBA, I extract this and put the results in a spreadsheet.
It's then easy to track the status of the document.

It's something easy to do in MS Word but not in Google docs. I can't find any way to access the comments from a google app script.

Do you know if such way exist?

Something like Document.getBody().getComments().

If you have any solution, I would be happy to know as I can't anything on the net.

1
Unfortunately, there are no methods for retrieving comments in the class of DocumentApp yet. So when you want to retrieve them, please use Comments: list of Drive API. You can also use Drive API of Advanced Google services. - Tanaike
Thanks for your feedback Tanaike. I am less experienced with Google drive API. Do you have any code example that shows how to access the google drive API from the google app script? Thanks - Pierre Lemoine
I'm really sorry I didn't provide samples. For example, the usage for Drive API of Advanced Google Services is stackoverflow.com/questions/50877531/… About Drive.Comments.list, you can see at stackoverflow.com/questions/22600843/… - Tanaike

1 Answers

4
votes

Thanks. I found something in the API in the meantime.

function listComments() {
  var comments = Drive.Comments.list(DocumentApp.getActiveDocument().getId());

  if (comments.items && comments.items.length > 0) {
    for (var i = 0; i < comments.items.length; i++) {
      var comment = comments.items[i];  
      Logger.log('Comment : %s', comment.toLocalString());
    }
  } else {
    Logger.log('No comment found.');
  }
}