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:
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:
- Flow will use a SharePoint trigger – when a new file is added to the library.
- Get file metadata which gives us the ETag property (along with many others) we need which is required when dealing with content approvals.
- ETag is a special identifier that identifies the specific version of that item that is pending approval.
- Start an approval action:
- Include people for approving the documents.
- Approvers should be either Site Owners or Site Members.
- If you are managing users in SharePoint groups, then make sure approvers are part of the Design permission level group.
- If approval response is approved:
- Set content approval status of the document to Approved.
- Send an email to the document author regarding the approval along with any comments.
- If approval response is not approved:
- Set content approval status of the document to Rejected.
- 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.
Now you can add the actions as described in the steps above.
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
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.
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.
- Using the Id property from the trigger output
- Using the comments property from the approval response
- 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:
- Once the flow is triggered, approvers get an email to approve/reject the document with the document link.
- Approvers can now:
- If your email client supports Outlook actionable messages: Approve it within the email using actionable messages if your Outlook client supports it.
- 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.
- One approved or rejected:
- Document creator will get an email with the approval status along with the approval comments.
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!