Search code examples
google-apps-scriptgoogle-drive-apigoogle-docsgoogle-docs-apigoogle-drive-shared-drive

Get the Approval Process Version Name/Number of a doc with Apps script


There is a recent "Approvals" feature in Google Docs that is currently available only for:

Google Workspace Essentials, Business Standard, Business Plus, Enterprise Essentials, Enterprise Standard, Enterprise Plus, Education Plus, and Nonprofits, as well as G Suite Business, G Suite Enterprise, Drive Enterprise, G Suite for Education, G Suite Enterprise for Education, and G Suite for Nonprofits

Not available to Google Workspace Business Starter, Education Fundamentals, Education Standard, Frontline, and G Suite Basic customers

Not available to users with personal Google Accounts

Here is a brief description of the process: https://gsuitetips.com/tips/docs/how-to-request-approvals-in-google-docs/

Each approved version of the document will receive a Version name like "Version 1", "Version 2" etc.

I am looking for a way to get this version name using Google Apps script and add it to the document footer.

I have tried the code snippet from https://developers.google.com/apps-script/advanced/drive#listing_revisions

/**
 * Lists the revisions of a given file. Note that some properties of revisions
 * are only available for certain file types. For example, G Suite application
 * files do not consume space in Google Drive and thus list a file size of 0.
 * @param {string} fileId The ID of the file to list revisions for.
 */
function listRevisions(fileId) {
  var revisions = Drive.Revisions.list(fileId);
  if (revisions.items && revisions.items.length > 0) {
    for (var i = 0; i < revisions.items.length; i++) {
      var revision = revisions.items[i];
      var date = new Date(revision.modifiedDate);
      Logger.log('Date: %s, File size (bytes): %s', date.toLocaleString(),
          revision.fileSize);
    }
  } else {
    Logger.log('No revisions found.');
  }
}

but this is getting the revision numbers of files that are not the same as the version numbers of the Approval process.

Is there any way to get the version numbers of the Approval process? Thanks.

Approval Versions


Solution

  • No, there is no way to do it. The only way to interact with the approval system is via web UI. There is still no available documentation on the approval feature on the Drive API. (Give it time since this is still recent)

    Although, this was already requested as a missing feature here and so far, has no development updates.