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

Delete added excel file if flow fails from Sharepoint

Hi, 
I have a flow that adds an excel file into the SharePoint library and starts to make some changes in the excel file. 
I want to delete the excel file if my flow fails.
I have tried using the ``delete file`` action, but it's not working. Probably, while flow running excel file is getting locked. 
Does anybody have an idea?

3 REPLIES 3
manuelstgomes
Super User
Super User

HI @Serbay 

 

Can you please share the Power Automate and obfuscate anything private that you can't share so that I can have a better understanding of what you're trying to do and the issues.

 

I need to check what's your strategy to try to understand what may be wrong.

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

Hi, 
sure here is a sample,

Serbay_0-1612514999663.png

The last step is to delete the file if the run script action fails. Flow is working perfectly fine but doesn't delete the file if an error occurs.
If I go to SharePoint library and wants to delete it manually, it does display information as,

Serbay_1-1612515555514.png

I'm assuming this is the reason why the file can not be deleted. It's getting locked by me cause of changes that I'm making during the flow run.



manuelstgomes
Super User
Super User

Hi @Serbay 

 

Indeed we need to wait sometime for the changes to end and the file to be "released." How much time? We don't really know since it's not documented or can be predicted. These are the worse cases to deal with. 

 

I found an article where the author proposes a look at waits until the file is released

https://www.timlinenterprises.com/power-automate-file-lock-fail/

 

This may work, but I'm completely against "do until" actions, especially if you don't know when they will end. I would have a variable with the number of tries and, if it goes over, those tries stop the Flow.

 

Can you please check if and let me know if you have any questions?

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

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!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Top Solution Authors
Users online (1,414)