0

We have a flow which create a new file as follow (this will create a new version of the file, by replacing existing file):-

enter image description here

and we set the following setting for the create a new file action:-

enter image description here

when the flow run, sometimes it raise this error "The file ***** is locked for shared use by ***":-

{"statusCode":400,"headers":{"Vary":"Origin","X-SharePointHealthScore":"3","X-MS-SPConnector":"1","X-SP-SERVERSTATE":"ReadOnly=0","DATASERVICEVERSION":"3.0","SPClientServiceRequestDuration":"35","X-DataBoundary":"None","X-1DSCollectorUrl":"https://mobile.events.data.microsoft.com/OneCollector/1.0/","X-AriaCollectorURL":"https://browser.pipe.aria.microsoft.com/Collector/3.0/","SPRequestGuid":"c4f55cdf-f772-45fc-b018-3abf500128cc","request-id":"c4f55cdf-f772-45fc-b018-3abf500128cc","MS-CV":"31z1xHL3/EWwGDq/UAEozA.0","Strict-Transport-Security":"max-age=31536000","X-FRAME-OPTIONS":"SAMEORIGIN","Content-Security-Policy":"frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com *.powerapps.com *.yammer.com *.officeapps.live.com *.office.com .stream.azure-test.net .microsoftstream.com .dynamics.com .microsoft.com;","MicrosoftSharePointTeamServices":"16.0.0.22713","X-Content-Type-Options":"nosniff","X-MS-InvokeApp":"1; RequireReadOnly","Timing-Allow-Origin":"","x-ms-apihub-cached-response":"true","x-ms-apihub-obo":"true","Cache-Control":"max-age=0, private","Date":"Tue, 26 Jul 2022 14:44:44 GMT","P3P":"CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"","X-AspNet-Version":"4.0.30319","X-Powered-By":"ASP.NET","Content-Length":"348","Content-Type":"application/json","Expires":"Mon, 11 Jul 2022 14:44:44 GMT","Last-Modified":"Tue, 26 Jul 2022 14:44:44 GMT"},"body":{"status":400,"message":"The file https://********.sharepoint.com/sites/CMS/Contracts/612/-Entity Consultancy Contract.docx is locked for shared use by hahmed@.org [membership].\r\nclientRequestId: c4f55cdf-f772-45fc-b018-3abf500128cc\r\nserviceRequestId: c4f55cdf-f772-45fc-b018-3abf500128cc"}}

any advice how we can avoid this error permanently ? For example, can we force unlock the file before creating a new version of it?

1 Answer 1

1

I don't think you can force unlock the file. What I have done in these situations is to put the action in a Do Until loop and use Run After checking to see if the action failed. The setup goes like this:

Initiate a variable to False
Do Until variable is True
   Create File action
   Delay 5 minutes - Run after Create File = Failed or Timed Out
   set variable to True - Run after Delay action is skipped

So, if the file creation succeeds, the Delay step is skipped, the variable is set to TRUE and the flow continues.

If, however, the file is locked and causes the Create File action to fail, the next action is a 5 minute delay, and the variable stays at FALSE. After 5 minutes, the Create File action is attempted again. Rinse and repeat.

4
  • Thanks for the reply.. but if a user opens the files inside his desktop app or inside the browser and edit the document, then we will keep getting the same error even if we wait for 5++ minutes, am i correct?
    – John John
    Commented Jul 26, 2022 at 23:24
  • 1
    Then it waits 5 minutes more. And then checks again. And then it waits 5 minutes more. It will keep doing that until the file is no longer locked, so the delay is skipped and the variable is changed to TRUE. You can configure how many repeats you want to allow for the loop. You could also include an increment counter and when the counter has reached a certain number, fire off an email to the person who has the file locked, which is probably the person who last modified it.
    – teylyn
    Commented Jul 27, 2022 at 0:34
  • ok got your point, but how i can know the person who is locking the file/
    – John John
    Commented Jul 27, 2022 at 10:00
  • 1
    As I said, most likely the person who last modified it, which you can get from the properties. Depending on how you set up the Do Until, it can run for days, so the chances of the file getting closed increase with every delay.
    – teylyn
    Commented Jul 27, 2022 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.