Hey everyone! I’m trying to figure out how to access suggestions in a Google Doc using only Google Apps Script. I’ve seen some info about doing this with Java or Python, but I’m not familiar with those languages. I just want to check if there are any suggestions in the document without changing them. Does anyone know if there’s a way to do this with Apps Script? I’ve been searching online but haven’t found a clear answer. Any help or tips would be really appreciated! Thanks in advance for your time.
As someone who’s worked extensively with Google Apps Script, I can tell you that unfortunately, there’s no direct way to access suggestions in a Google Doc using only Apps Script. The Suggestions feature is not exposed through the Apps Script API.
However, there’s a workaround you might consider. You can use the Document.getBody().getText() method to get the full text of the document, including suggested edits. Then, you could parse this text for the special characters that Google Docs uses to denote suggestions (like [[ and ]]).
Keep in mind this method isn’t foolproof and won’t give you detailed information about each suggestion. But it could at least help you detect if there are any suggestions present in the document. If you need more robust functionality, you might need to explore using the Google Docs API with a different programming language.
I’ve actually encountered this issue before in my work. While emmad is correct that there’s no direct method in Apps Script to access suggestions, I found a different workaround that might be helpful.
Instead of parsing the text, you can use the Document.getRevisions() method to get all revisions of the document. Suggestions are technically revisions that haven’t been accepted yet. By iterating through these revisions and checking their types, you can identify which ones are suggestions.
Here’s a rough outline of the approach:
- Get all revisions using getRevisions()
- Loop through each revision
- Check if the revision type is SUGGESTION_INSERT or SUGGESTION_DELETE
This method isn’t perfect either - it won’t give you the content of the suggestions, just their presence. But it’s more reliable than text parsing and doesn’t require understanding suggestion formatting.
Remember to test thoroughly, as Google’s APIs can sometimes change without notice.
hey there dancingbird! sadly, apps script doesn’t have a built-in way to check suggestions
but you could try using the Document.getRevisions() method. it might help spot suggestions as unaccepted revisions. not perfect, but could work for what u need. good luck with ur project!