1

I need to write a very simple script for retrieving the comments added to a file using the file ID, and store the comments to the activesheet I have found this page but I don't really know how to get the code running with an app script.

function retrieveComments(fileId, callback) {
var request = gapi.client.drive.comments.list({
'fileId': fileId
});
request.execute(callback);
}    

Every time I run the code I just get this error:

ReferenceError: "gapi" is not defined. (line 2, file "Comment").

Any help will be highly appreciated!

4
  • this code don't look like google apps script maybe something more like the google javascript library Commented Mar 24, 2014 at 10:25
  • Do you need to retrieve the "comment" of a google file (google Document, google spreadsheet) or the "description" that is added to all kind of document stored on google drive? Commented Mar 24, 2014 at 10:38
  • Thanks for the replies! This is not from the apps script library but the Google Drive API. I really wonder why they have addcomments and removecomments methods but no listcomments method for google app script Commented Mar 24, 2014 at 13:06
  • by "comments" I need to retrieve the comments added to some pictures using the google drive viewer. developers.google.com/drive/v2/reference/comments/list the try it now at the bottom actually does what I need but I want to be able to do the same within a google spreadsheet and its attached scripts Commented Mar 24, 2014 at 13:09

1 Answer 1

1

the short answer:

Drive.Comments.list(id)

the how to:
"Drive" is a call to the drive api but this is still experimental, in your script you need to go in "ressources > advanced google services" and activate the Drive API. You also need to follow the link at the end "These services must also be enabled in the Google Developers Console." and activate the drive API there.

here an example:
you can add a comment to this google document
and then have a look at this script webapp to retrieve all the comments.
the source code of the webapp is here (It's a little mess in there, because I used two differents methods to get the Drvie API to work)

Sign up to request clarification or add additional context in comments.

2 Comments

wow thanks! this is really helpful indeed! let me study the code and implement to my little project!
Here is a full example that uses the Drive API service, and handles pagination.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.