0

I would like to get a list of comment and reply from doc and add content of comment and reply in sheet (3 first comments and replies) structured as:

Name of the file | date | update date | Url | Comment1 | reply1 | Comment2 | reply2 | Comment3 | reply3

The script I have now:

    function listfichier(){
     var sh = SpreadsheetApp.getActiveSheet();
     var folder = DriveApp.getFolderById('ID_of_folder'); 
     var list = [];
     list.push(['Name', 'Date','update date', 'URL', Comment]);
     var files = folder.getFiles();
     
     while (files.hasNext()){
     file = files.next(); 
    var comments;
    comments = Drive.Comments.list(file.getId());
    Logger.log (comments.items.length);
    if (comments.items && comments.items.length > 0) {
      for (var i = 0; i < comments.items.length; i++) {
        var comment = comments.items[i];
      }
        var row = []
       row.push(file.getName(),file.getDateCreated(),file.getLastUpdated(),file.getUrl(), comment.content, comment.replies)
       list.push(row);
    } else {
      Logger.log('No comments found.');
    }

     }
      sh.getRange(1,1,list.length,list[0].length).setValues(list);
    }

Is this even possible?

Toufik
  • 1
  • 1
  • Apart from closure as duplicate : could you please clarify what exactly is you want to do here? We understand that you want to create a list of comments, but is there a problem with your code? – Oleg Valter is with Ukraine Jul 10 '20 at 18:21
  • sorry, i don't want to create comments. I have pdf files on the google drives, users can create comments and replies on the files. I want to read these comments, replies and save it on the sheet in this script i can't read the replies content for files – Toufik Jul 11 '20 at 22:18
  • if you need replies, you should look into [`Replies` resource](https://developers.google.com/drive/api/v3/reference/replies), not comments. Btw, yeah, I get that you do not want to create comments, but you want to create a *list* of them and set to a sheet, right? – Oleg Valter is with Ukraine Jul 11 '20 at 22:21
  • yes. i want to create a list of both (comments and replies) and set to a sheet. thanks – Toufik Jul 11 '20 at 22:46
  • So... is there a problem, do you get an error, the script takes too long to run to completion, no replies are returned? – Oleg Valter is with Ukraine Jul 11 '20 at 23:06
  • i need return just content and displayName Property of reply – Toufik Jul 11 '20 at 23:26

0 Answers0