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
Thank it is great. I am new to sharepoint and I was looking for something like this. Thanks
LikeLike
Hi Peter,
Glad to hear it and thanks for reading!
NY
LikeLike
this i sn’t working for me. still shows same error, file is locked for exclusive use
LikeLike
Hi Rishi,
There could be a number of “things” locking the file. FIle is currently checkout, compliance locking, co-authoring, process activity etc.
Test with a simple document library to ensure that the aforementioned “things” are not affecting your test Flow.
Thanks for reading!
NY
LikeLike
Once file is approved can we restrict sharepoint members from editing it? how we can achieve that?
LikeLike
Hi Dev,
You could change the file permissions to read only within your Flow. I haven’t done it but the actions exist.
Thanks for reading!
NY
LikeLike
Hi NY,
Thanks for your prompt reply. I am new to this. If you can provide more guidance it will be helpful.
LikeLike