cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How to check if a file exists in a SharePoint library by file name?

I am trying to get a true/false response on if a file exists in a SP library given the file Name. The files do not have Titles. Based on my research, I have seen suggestions to use the Get file content using path action. I am able to test that and I do get that to run successfully. However, I don't know where to go from here. I'd like to have a condition after to essentially check if the file was found. What would it be checking on?

Edit: Now thinking Get file content using path is not the best action because the Flow fails on a bad path which I don't want to happen

1 ACCEPTED SOLUTION

Accepted Solutions
RezaDorrani
Dual Super User II
Dual Super User II

Hi @Anonymous 

 

Use get files properties only

do query on file name and then check the length using expression 

 

Untitled.png

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

9 REPLIES 9
RezaDorrani
Dual Super User II
Dual Super User II

Hi @Anonymous 

 

Use get files properties only

do query on file name and then check the length using expression 

 

Untitled.png

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

v-alzhan-msft
Community Support
Community Support

Hi @Anonymous ,

 

Have you take a try with @RezaDorrani 's workaround, you could take a try to achieve your needs.

 

Have your problem be solved?  If yes, please go ahead and mark the post as solved by clicking “Accept as Solution” so that this thread will be marked for other users to easily identify!

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

But what do you do once you check the condition? How does that translate back to powerapps to complete the check?

Hi @RezaDorrani 

 

I have been trying to duplicate the solution you described. I got error:

The expression "FileLeafRef eq INS-TEST----.pdf" is not valid. Creating query failed.
clientRequestId: 35c0a1f9-d680-46e2-bdd2----
serviceRequestId: 35c0a1f9-d680-46e2-bdd2---

 

Can you please advise what might be the issue?

 

Thank you in advance.

Hi @RezaDorrani 

I see the issue I had not using single quotes for the file reference, after it was fixed, it has been working well. Sorry for the unnecessary question not noticing the typo issue at first.

Thank you.

Thanks Reza, your solution helped me solve a problem.

AndresBMR96
New Member

This solution is superb! One thing you could do if you want to compare various files rather than just one file change

FileLeafReq eq 'contratc.docx' 

to:

FileLeafReq eq '[FILE NAME]' 

Where [FILE NAME] is a string variable of the "display name" of the file )which you can get from a "get. attachments" function.

rsadhula
Regular Visitor

Hi @RezaDorrani ,

FileLeafReq eq 'contratc.docx' 

Above filter doesn't work if we have more than 5000 items in library, Do we have any alternative for this ?

 

I'm using the odata filtering on a library with 20k+ items without issue.

 

FileLeafRef eq 'filename.pdf' 

 


Note the  FileLeafRef   name.

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.

Users online (1,116)