cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LostLogic
Frequent Visitor

Check if file exists in SharePoint without flow returning failed status

Hello all.

So, I've followed the blog-post regarding how to check if a file exists in a SharePoint Folder. (1) Solved: Check if file exists in Sharepoint folder - Power Platform Community (microsoft.com)

This works great, however the Flow status ends up as "Failed" even though it's run successfully.

Is there a way to suppress the Get Metadata step failure that is handled by a scope, or do I have to live with the flow kicking up failed statuses.

LostLogic_0-1623736945797.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Ended up with this logic.

LostLogic_0-1623743707936.png

Do a Get Files (Properties Only) limited to the library and folder, as well as filtered on FileLeafRef (Filename) with a max count of 1. If 1 is found : Great! The file exists. If less than 1, it doesn't and continue the logic from there.

Thanks for putting me on the right path Bof!

View solution in original post

4 REPLIES 4
v-bofeng-msft
Community Support
Community Support

Hi @LostLogic :

Do you want to check whether a file with the specified name exists in a certain SP library?

If so,I suggest that you can get all the files in this library first, and then filter the items by file name.If the result of the filter is empty, then the file does not exist.

I've made a test for your reference:

v-bofeng-msft_1-1623741405641.png

The result:

the file exist

v-bofeng-msft_2-1623741440668.png

 

the file does not exist

v-bofeng-msft_0-1623741349617.png

Best Regards,

Bof

 

This would be an excellent solution had it not been for the amount of files and non-guaranteed unique file names. I could probably filter on path as well, but getting all file properties in a document library on every run of a loop will slow down the flow significantly.

But! I think you've put me on the right path. I can use the Get Files (Properties Only) action to limit to folder and filter on name. If the count is equal to 0, I know it doesn't exist.

Thanks!

Ended up with this logic.

LostLogic_0-1623743707936.png

Do a Get Files (Properties Only) limited to the library and folder, as well as filtered on FileLeafRef (Filename) with a max count of 1. If 1 is found : Great! The file exists. If less than 1, it doesn't and continue the logic from there.

Thanks for putting me on the right path Bof!

Hi @LostLogic :

Thanks for your feedback.

Glad to hear that you solved this problem.

Beast Regards,

Bof

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,687)