Unlock documents

In 2019 I wrote a post about SharePoint file locks and how to handle these with a retry pattern. But there is an easier way when you use child flows.

SharePoint File locks

In this post I will use the following flow as an example:

Handling SharePoint file locks with Power Automate child flows Microsoft Office 365 image 8

So when a file is create an update to the file properties will fail with the following error message

The file “…/Document.docx” is locked for shared use by ..

SharePoint File locks

When looking at the details of the Update file properties action we see a bad requst

Handling SharePoint file locks with Power Automate child flows Microsoft Office 365 image 9
Handling SharePoint file locks with Power Automate child flows Microsoft Office 365 image 11

And when we look at the retry settings we can see that the error 400 doesn’t result in a retry process kicking in.

Handling SharePoint file locks with Power Automate child flows Microsoft Office 365 image 10

How do we handle the file lock. There are two options. Option 2 is definitely my preferred option!

Option 1 – Retrying using a child flow

To find out more about child flows please have a look at my posts about getting started with child flows.

I’m going to move my update file properties into a child flow:

Handling SharePoint file locks with Power Automate child flows Microsoft Office 365 image 12

And in my main flow I’m going to call my child flow instead of the update of the file properties action. As you can see both the actions look fairly similar to configure, making the replacement an easy task to complete.

Handling SharePoint file locks with Power Automate child flows Microsoft Office 365 image 13

So now we should end up with the following flow

Handling SharePoint file locks with Power Automate child flows Microsoft Office 365 image 14

And when we create a document the retries as kicking in:

Handling SharePoint file locks with Power Automate child flows Microsoft Office 365 image 15

And when we then close the word document that we created the flow will complete with retries. The amber warning sign will however remain in place indicating that there were retries happening before completion.

Handling SharePoint file locks with Power Automate child flows Microsoft Office 365 image 16

This solutions to retrying file updates when a document is kept open making it a lot easier to handle SharePoint file locks as it uses the out of the box retry mechanism available with Power Automate.

In this case I used the file properties update, but I could quite well imagine that there are other scenarios where it would be useful to retry using a child flow.

Option 2 – Handling file locks using system updates

The second option is all based on doing system updates rather than basic updates. For the details on this approach please read my post about system updates.

Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading