cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Advocate I
Advocate I

Power Automate Handling - Document is locked for shared use by user

Hi All,

 

I have created a simple approval workflow that updates the Document's status column as it goes through the different stages (pending, approved or rejected) of approval. 

Occasionally, the workflow fails (while updating the status - pending in this example) with an error saying the documents is locked for shared use by a user. I understand this may happen if the user kept the document still open or did not close it properly.

 

My question is what is the best way to handle such scenarios. Can anyone with similar experience share your ideas please ?

 

workflow error.png

1 ACCEPTED SOLUTION

Accepted Solutions

@Paulie78 : Thanks for your response.

I also found this article which talks about this issue

https://sharepains.com/2019/09/26/file-locks-sharepoint-power-automate/

Basically he suggests to send HTTP Request to check if the file is locked or not and if locked, wait until it gets unlocked.

 

The API suggest in this article has been deprecated. The new API is this
/_api/Web/GetFileByServerRelativePath(decodedurl='Site relative URL of the document')/LockedByUser

View solution in original post

4 REPLIES 4
Memorable Member
Memorable Member

Like this...

https://ibb.co/1ZTgLV2 (Image link because I find the viewer on here so annoying!

Wait-Until-File-Is-Not-Locked.png

Code on the if expression is:

if(equals(outputs('Update_file_properties')?['body']?['status'],400), true, false)

Basically it checks if the error response was 400, which is what it gives when the file is locked for editing and waits for it to become available.

 

I just tried it out and it resumed after the file was closed.

 

Let me know how you get on.

 

If I answered your question Accept it as a solution ✔️ 

If I helped you out, please give me some Kudos 👍

Thanks 😙

 

Slight update, change the last step to look like this:

Wait-Until-File-Is-Not-Locked-Delay.png

This will change the delay to only 1 second if the file is not locked and make it 90 seconds if it is.

@Paulie78 : Thanks for your response.

I also found this article which talks about this issue

https://sharepains.com/2019/09/26/file-locks-sharepoint-power-automate/

Basically he suggests to send HTTP Request to check if the file is locked or not and if locked, wait until it gets unlocked.

 

The API suggest in this article has been deprecated. The new API is this
/_api/Web/GetFileByServerRelativePath(decodedurl='Site relative URL of the document')/LockedByUser

View solution in original post

No worries, that is useful to know. Glad you sorted it.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Top Kudoed Authors
Users online (11,861)