cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Beat
Helper V
Helper V

SharePoint create file action fails as file either already exists or file is locked

I'm trying to build a quite simple flow, pulling some file contents via HTML GET, create an Excel file with a table and then list some filtered rows from that table. In order to setup that flow I had to create the tempClosure.xlsx in the destination folder, containing Table1
Closure Report flow.png

To my utter satisfaction, this worked like a charm on the first try 

Closure Report 1st run.png

But next time it failed with 

The file https://{tenant}/sites/{site}/GRDA/Closure Report/tempClosure.xlsx is locked for shared use by {me}

 

I then added a step to delete the file after use. Now the Create File action succeeded, but the List rows present in a table step failed, because it referred to the original table ID, which no longer existed:
No table was found with the name '{301239FC-7969-4BFC-8010clientRequestId: 3a02dda4-663a-4466-9b32-5d8e90a6a4bf

 

As suggested in several posts in the community, I added a check-in step before the create file action to ensure the file is not checked out. That worked as well on the first try, but again just once. Next run failed with the same initial error
The file https://{tenant}/sites/{site}/GRDA/Closure Report/tempClosure.xlsx is locked for shared use by {me}

Why is that file locked for shared use by me? When I open it from the SP Library, it says 

To prevent accidental changes, the author has set this file to open as read-only. [Edit Anyway]


May this be causing the issue? I'm not aware of where the flow would set this flag, is there a way to supress/remove it?

 

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User
Super User

Hi @Beat 

 

Interesting issue. Couple of things to check.

 

1. Add a delay before you create the file.

2. Check the SharePoint library settings not enabled for default checkout.

 

Try the first option. If that doesn't work then try the second one. Let me know the results.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

7 REPLIES 7
abm
Super User
Super User

Hi @Beat 

 

Interesting issue. Couple of things to check.

 

1. Add a delay before you create the file.

2. Check the SharePoint library settings not enabled for default checkout.

 

Try the first option. If that doesn't work then try the second one. Let me know the results.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

@abm thanks for your prompt reply. Default checkout wasn't enabled on the library.

I added a delay of 2 minutes, it still failed. Then I tried 10 minutes and it timed out.

After dozens of tests, it turns out that 8 or 9 minutes of delay do the trick.

6 minutes mostly fails, 7 minutes rarely, 8 or 9 never, and 10 minutes times out. Truly interesting.

Beat_0-1630534359113.png

So I'm gonna go for 8. But WHAT THE HECK is locking that file approx. 7 minutes before my flow is actually going to attempt to overwrite it? It can only be my flow itself, but HOW and WHY? For a moment I thought it would by the interval between flow runs, but no, if I launch it with 7 minutes delay immediately upon a completed or failed run, it most likely will succeed, but if I launch it with 6 minutes delay hours after the previous run, it is still very likely to fail. What kind of logic is behind all of this???

Hi @Beat 

 

This could be behind the scene system is doing something. I could offer another logic. Once the process is done can't you move the file to another location so that always the file creation won't complain about the lock out. Anyway glad to hear that the delay technique was useful. Thanks a lot for the update.

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

@abm thanks, but no, I can't move the file as otherwise in the next run, the list rows in a table action will will fail with "No table was found with the name '{301239FC-7969-4BFC-8010)". Although the filename and table name are the same, it is linked to the original table ID rather than the table name.

Hi @Beat 

 

This blog might help

 

Power Automate – Excel Dynamic Filename – Flow Alt Delete – Josh Cook [Microsoft MVP]

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

With 8 minutes delay it still failed once upon a time, set it to 9 and cross fingers. 

Hi @Beat 

 

Its worth raising with Power Automate Microsoft support team as well. 

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (3,323)