cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
imran7799
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
Paulie78
Super User III
Super User III

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
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (3,123)