cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Carl__D
Helper I
Helper I

Get Files 'Filter Query' continues if no items are found

Hello, 

 

I've got a flow with a 'Get Files' Filter Query that gets files from SharePoint where the 'Review Date' date-column equals today:

Carl__D_0-1631267581090.png

 

When there is a file that matches the query this continues to the next steps and succeeds. 

My issue is when there are no files that match the query the flow still continues then inevitably fails further down. 

 

I have tried setting a condition after the Get Files to terminate if there are no results (with something like 'IF 'Value' = null THEN terminate') but can't seem to find one to work!

 

Any help is much appreciated. 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ekarim2020
Super User
Super User

In that case, you can add a condition to check if any results were returned. You can check the length of the value property:

length(outputs('Get_files_(properties_only)')?['body/value'])

 

ekarim2020_0-1631280872159.png

Condition evaluates to true:

ekarim2020_1-1631281120244.png

Example where condition evaluates to false - no results were returned:

ekarim2020_2-1631281143094.png

Ellis

 

View solution in original post

4 REPLIES 4
ekarim2020
Super User
Super User

 

This is because the value of the dates are different, as UtcNow() returns very detailed date-time info:

For example, a review date field in one of my document library is:

"ReviewDate": "2021-09-27"

UtcNow() returns  '2021-09-10T11:08:16.2091212Z'

2021-09-27 (ReviewDate) is not equal to 2021-09-10T11:08:16.2091212Z (UtcNow) - so no matching records are returned:

ekarim2020_0-1631272711387.png

You can adjust the output of the UtcNow() function by specifying the output format using 'yyyy-MM-dd':

ekarim2020_2-1631272830302.png

Now if you run your query it should then return some results:

ekarim2020_1-1631272737137.png

ekarim2020_3-1631273095021.png

Ellis

Hi Ellis, 

 

Thanks for your reply!

 

The flow works and I do have that expression in the Filter Query. 

The issue is if there are no results that match the query, the flow doesn't stop there, it still continues but with no data so fails. 

I assumed it would stop if there were no files that matched the query but as it doesn't I need a way to stop it 🤔

ekarim2020
Super User
Super User

In that case, you can add a condition to check if any results were returned. You can check the length of the value property:

length(outputs('Get_files_(properties_only)')?['body/value'])

 

ekarim2020_0-1631280872159.png

Condition evaluates to true:

ekarim2020_1-1631281120244.png

Example where condition evaluates to false - no results were returned:

ekarim2020_2-1631281143094.png

Ellis

 

Worked a treat, thank you!

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.

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.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (2,057)