2

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.

Nakilon
  • 34,866
  • 14
  • 107
  • 142
  • 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](https://developers.google.com/drive/api/v3/reference/comments/list). You can also use Drive API of [Advanced Google services](https://developers.google.com/apps-script/guides/services/advanced). – Tanaike Jun 18 '18 at 22:34
  • 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 Jun 19 '18 at 09:05
  • I'm really sorry I didn't provide samples. For example, the usage for Drive API of Advanced Google Services is https://stackoverflow.com/questions/50877531/script-for-a-google-doc-makecopy-the-comments-arent-copied/50885948#50885948 About ``Drive.Comments.list``, you can see at https://stackoverflow.com/questions/22600843/how-to-list-comments-of-google-drive-files-using-google-app-script – Tanaike Jun 19 '18 at 11:42

1 Answers1

4

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.');
  }
}