Extracting Google Docs approval workflow data with Apps Script?

Hey everyone! I’m a beginner with Google Apps Script and I’m trying to figure out how to get approval workflow info from a Google Doc. I want to print this info right in the document.

Here’s what I’m looking to extract:

  • Has the doc been locked for approval?
  • Who was the last person to approve it and when?
  • Who else needs to approve?

I’ve looked around but only found how to get the last editor and edit time:

let lastEdit = DriveApp.getFileById(docId).getLastUpdated();
let lastEditor = Drive.Files.get(docId, {supportsTeamDrives: true}).lastModifyingUserName;

But this doesn’t tell me anything about the approval workflow. Any ideas on how to get the info I need? Thanks!

hey there! i’ve been messing with google docs approvals too. sadly, the API doesn’t let us grab that data directly :frowning: but here’s a trick - make a google sheet to track approvals, then use apps script to add custom buttons in your doc. when someone approves, it logs in the sheet. then u can pull that info back into the doc. not perfect, but it works!

As someone who’s wrestled with this exact problem, I can tell you that unfortunately, Google Docs’ approval workflow data isn’t directly accessible via Apps Script. It’s a frustrating limitation I’ve encountered in my own projects.

However, I’ve found a workaround that might help. Instead of relying on the built-in approval system, I created a custom approval process using a combination of Google Sheets and Apps Script. Here’s the gist:

  1. Set up a Google Sheet to track approvals
  2. Use Apps Script to add custom menus to your Google Doc
  3. When an approver clicks the custom menu item, it logs their approval in the Sheet
  4. You can then use Apps Script to read from this Sheet and display the approval status in the Doc

It’s not as elegant as accessing native approval data, but it gives you full control and the ability to extract exactly what you need. Plus, you can customize it to fit your specific workflow. Hope this helps!

Having worked with Google Docs and Apps Script, I can confirm that retrieving native approval workflow data is not feasible because the current API does not support it. In my experience, I implemented a custom solution by integrating a Google Sheet as a backend. I added custom menu items to the Doc to capture approval actions and log them. Although this method involves more initial work, it offers better control and flexibility to meet unique workflow requirements without relying on native functions.