in Flow, SharePoint

Require approval of documents in SharePoint using Microsoft Flow

Documents that contain sensitive information often require approvals. With the content approval feature in SharePoint, you can put a simple approval process for documents in a specific document library. Using this content approval process, documents pending approval will not be visible to users unless it is approved.

You can manage the content approval settings in the library settings page:

setup-content-approval-settings

Settings->Versioning settings->Require content approval for submitted items

Once this is enabled, when users upload documents to this specific library, the document’s Approval Status is either in Draft (if minor & major versions are enabled) or Pending (if the only major version is enabled) state.

You can always visit the document library to approve and reject documents but that is tedious as you will have to get notified somehow about the pending documents, and then find the right documents, approvers and the command to approve/reject.

So, why not automate this approval process using a flow?

Content approval flow

You can automate this entire content approval process using an approval flow which when approved will set the content approval status of the document to Approved and if rejected will set the content approval status of the document to Rejected.

To set the content approval status of the document, we will use the Set content approval status action in the flow which is available under the SharePoint connector.

Below is what our flow will do:

  1. Flow will use a SharePoint trigger – when a new file is added to the library.
  2. Get file metadata which gives us the ETag property (along with many others) we need which is required when dealing with content approvals.
    1. ETag is a special identifier that identifies the specific version of that item that is pending approval.
  3. Start an approval action:
    1. Include people for approving the documents.
    2. Approvers should be either Site Owners or Site Members.
    3. If you are managing users in SharePoint groups, then make sure approvers are part of the Design permission level group.
  4. If approval response is approved:
    1. Set content approval status of the document to Approved.
    2. Send an email to the document author regarding the approval along with any comments.
  5. If approval response is not approved:
    1. Set content approval status of the document to Rejected.
    2. Send an email to the document author regarding the rejection along with any comments.

Setting up the flow

To start with, let’s create a flow using the following template. You can do this by clicking on the Flow->Create a flow button in the command bar in the library. We will use the template: When a new file is added in SharePoint, complete a custom action.

create-flow-template-file-added

Now you can add the actions as described in the steps above.

flow-content-approval-full

Set content approval status action

Let us look at the set content approval action specifically as that is what this is all about.

The content approval action takes few inputs:

  • SharePoint Site
  • Library Name
  • Identifier of the item (in our case, the document Id)
  • Content approval action
  • Comments

To see the ETag, you will need to expand the Show advanced options.

Note: While the content approval action help says that ETag is optional, it is required for documents and pages while it may be optional for list items. 

action-content-approval-status

You will need to ensure you input the correct site and library name. However, you can get the rest of the values from the previous actions in the flow.

  • Identifier
    • Using the Id property from the trigger output
  • Comments
    • Using the comments property from the approval response
  • ETag
    • Using the ETag property from the Get file metadata action output

You can now use the content approval status action to approve and reject the document based on the approval response.

The end result is that:

  1. Once the flow is triggered, approvers get an email to approve/reject the document with the document link.
  2. Approvers can now:
    1. If your email client supports Outlook actionable messages: Approve it within the email using actionable messages if your Outlook client supports it.
    2. If your email client does not support Outlook actionable messages: Click the Approve/Reject buttons that takes to Flow Approval center where you can approve/reject the document.
  3. One approved or rejected:
    1. Document creator will get an email with the approval status along with the approval comments.

output-content-approval-status

Simple yet effective way to automate document approval in SharePoint using Microsoft Flow! You should be able to use this for list items and pages as well.

As always, let us know if you have any feedback! We are always listening!

 

 

 

Write a Comment

Comment

  1. This is great. Thank you. How about a flow that will require approval before you can delete a file in SharePoint?