'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 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1