Search code examples
javascriptautomationgoogle-sheets-apispreadsheet

How Can I add comment on a cell using google sheet app script


How Can I add comment to google sheet using app script. I can add notes but i want to add comments. tried different methods but no clue.

.setcomments

and

.getcomments

function not even exisit.


Solution

  • I achive to add a comment with :

    function insertDriveComment(){
      var fileId = 'your file id'
      var resource = {'content': 'Here is my comment !'};
      Drive.Comments.insert(resource, fileId)
    }
    

    you have to enable Drive API service

    or, if you use the same spreadsheet to add comments

    function insertDriveComment(){
      var fileId = SpreadsheetApp.getActiveSpreadsheet().getId()
      var resource = {'content': 'Here is my comment !'};
      Drive.Comments.insert(resource, fileId)
    }
    

    to enable drive api service enter image description here