According to the article, when you use an Excel table in your flow, the Excel file remains locked for 6 minutes. Therefore, if you want to delete the file, you need to wait 6 minutes before executing the deletion.
Creating a Flow That Waits 6 Minutes Before Deletion
So, I created a flow that deletes the Excel file after waiting for 6 minutes.
First, add a “Do until” action with “Delete file” and “Delay” actions. Set up the left side of the Do Until condition like this:
outputs('Delete_file_action_name')['statusCode']
Set the condition to “is equal to” 200.
Then set the “Delay” action to 6 minutes. Note: Since the lock lasts approximately 6 minutes, you might want to try shorter intervals like 2 or 3 minutes for faster retry attempts if deletion fails. However, I’ll stick with 6 minutes for now.
Next, click on “Configure run after” for the “Delay” action:
Select “has failed” and click “Done” to complete the setup!
Testing the Flow
After running the flow, confirm that both “Create file” and “Get table” actions completed successfully.
Verify that the Excel file was properly created in the document library.
After approximately 6 minutes, the flow completed successfully!
Looking at the details, we can see that the first deletion attempt failed,
But the second deletion attempt after 6 minutes was successful!
And of course, the file was successfully deleted from the document library!
In conclusion, we’ve learned that when you need to delete an Excel file that has been referenced for its tables within the same flow, you must wait 6 minutes before the deletion can be successful.
コメント