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!

View solution in original post

Hi @LostLogic :

Thanks for your feedback.

Glad to hear that you solved this problem.

Beast Regards,

Bof

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (2,775)