Tech Community: Lock file for approval

This post is inspired by following Microsoft Tech Community conversation:

https://techcommunity.microsoft.com/t5/PowerApps-Flow/Locking-a-file-for-approval/m-p/876434

The user wants to “create a document approval flow whereby the document is locked during the approval process so it can’t be altered”. Using a custom Power Automate flow and SharePoint site columns we can lock the file and start a review and approval process.

In this demo I am using a standard document library called “LockOut” with two additional site columns called “AssignedTo” and “Status”.

Within your Document Library, click “Flow” and select “See you flows”.

Within Power Automate, click “New” and select “Automated – from blank”.

Provide a Flow name, i.e. “Lock file for approval”, select the SharePoint “When a file is created (properties only)” trigger and click “Create”.

Point it to your site and document library.

Add a “Update file properties” action. Point it to your site, document library, set “Id” equal to ID from the “When a file is created (properties only)” trigger and “Status Value” to Pending.

Add a “Check out file” action. Point it to your site, document library, set “Id” equal to ID.

Add a “Start and wait for an approval” action. Set “Approval type” to Approve/Reject – First to respond, “Title” to Name, “Assigned to” to AssignedTo Email, Details to Name, “Item link” to Link to item.

Add a “Condition” action and set Outcome (from the “Start and wait for an approval” action) is equal to Approve.

In the “If yes” branch add a “Check in file” action. Point it to your site, document library, set “Id” equal to ID, “Comments” to Approved and “Check in type” to Major version (publish).

Add a “Update file properties” action to the “If yes” branch. Point it to your site, document library, set “Id” equal to ID, “AssignedTo Claims” to AssignedTo Claims and “Status Value” to Approved.

In the “If no” branch add a “Discard check out” action. Point it to your site, document library, set “Id” equal to ID.

Add a “Update file properties” action to the “If no” branch. Point it to your site, document library, set “Id” equal to ID, “AssignedTo Claims” to AssignedTo Claims and “Status Value” to Rejected.

My completed Flow looks like this:

Upload a file to test and ensure that the “AssignedTo” site column is populated. In the image below the file is checked out and the status is set to “Pending”.

The “AssignedTo” person will receive the approval request email (see image below).

If approved, the document will be checked in and the status set to “Approved”.

If rejected, the document check out will be discarded and the status set to “Rejected”.

Thanks for stopping by.

Norm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s