Microsoft Flow - How to check if a file exists in SharePoint
I will start by describing my flow a bit.
In my flow I've got 2 document libraries. When a document is created in the first document library I want to copy the document to a second library and I'm doing this by using the Create file action. So my flow looks something like this:
But then I noticed in my flow history that every now and then I would get a create file going into retry mode as it was marked with the amber tick.
This was happening as users were making multiple updates to the same document very quickly after eachother. One of my flow instances would actually trigger and the second flow would go into this retry state.
So then I decided to add a 'does file exist' check. Unfortunately this action doesn't exist. But there is a great workaround available.
Before I run the create file action, In now added a get file content using path action followed by a scope that includes all the actions that I want to run after I create a new file.
To make this all work I set the scope's run after settings to
And now my check if file exist in my flow is complete.
Comments
-
Microsoft Flow - How to check if a file exists in SharePoint
I recently found a solution for checking to see if a list item exists that proved quite helpful. Basically you use Get Items with OData filters and then a custom condition to evaluate the response code. It's nice and tidy - none of the actions fail whether the item is there or not. I tested it out, and it works great.
I'm not positive if this method could be adapted to probe for documents succesfully, but it might be worth a shot.
-
Microsoft Flow - How to check if a file exists in SharePoint
The problem with your workaround is that flow still fails when Get content using path fails. Of course this activiity is logged.
One problem with your post is that we don't see the whole flow. It looks like you might have 2 conditions.
-
Microsoft Flow - How to check if a file exists in SharePoint
Thank you for posting this, I am in similar shoes, and was thinking of how to use REST to probe for filename existence but this technique seems faster. I will give this method a try.
-
Microsoft Flow - How to check if a file exists in SharePoint
Thank you for sharing the Microsoft Flow tips
*This post is locked for comments