0

I understand this is a total noob question. I would like to insert a pre-populated comment into a Google doc via Apps Script, with an option for a user to reply to the comment.

I have found this:

https://developers.google.com/drive/v2/reference/comments/insert

However, I am unsure how to embed this into my Apps Script. Does anyone have any sample code or would be able to point be in the right direction? I have only used Apps Script for simple tasks, and have not much experience with OAuth (I'm assuming I need this to get the code to work)

Thanks so much.

dacardzmasta
  • 91
  • 1
  • 5

2 Answers2

1

You're looking at the SDK documentation, which would be helpful if you're trying to write software that works with google drive.

What you want to look at is the apps script documentation, which is here: https://developers.google.com/apps-script/reference/document/

This isn't much of an answer, but I hope it points you in the right direction!

Don
  • 70
  • 6
1

Your question is similar to this one

This is the code we use:

function insertDriveComment(fileId, comment, context) {
  var driveComment = {
    content: comment,
    context: {
      type: 'text/html',
      value: context
    }
  };
  Drive.Comments.insert(driveComment, fileId);  
}

Of course you will need to activate the API in the Developper Console to manage oAuth. Just follow the steps here.

Keep in mind that you cannot attach programmatically the comment to words in Google Document like you can do manually, because anchors for Document Comments are proprietary (check the video at the bottom of the page here)

Hope it could help.

Community
  • 1
  • 1
denys
  • 81
  • 1
  • 2