How do I add a comment to a Google Doc with Google

2019-05-10 22:18发布

I was looking at the documentation and found no way to add a comment using Google Apps Script.

After scrolling a bit, I found out that the addComment() function was deprecated.

Is there currently any way to add a comment to a Google Doc using GAS (without using a deprecated script)?

1条回答
我命由我不由天
2楼-- · 2019-05-10 23:02

You can add comments using the Advanced Drive Service (That must be enabled before use. In the Script Editor select Resources > Advanced Google services... and then enable it in the Google Developers Console.)

Once enabled you can create a comment using Comments: insert.

Here's an example:

function myFunction(){
  var fileId = '{YOUR_DOCUMENT_ID}';
  var resource = {'content': 'Le comment'};

  Drive.Comments.insert(resource, fileId)
}

Then you can verify the comment in the Comments section of your doc:

enter image description here

查看更多
登录 后发表回答