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

Can't check the empty output from Filter Query (Get Items)

Hello experts,

 

I have 2 lists: CashAvanceRequest (where the requester inputs the info including the Job No) and ProjectListTest (info about the Job with Job Name and Approver Email).

 

In the case of matched Job No between the two lists, the flow run correctly.

 

However, when using the condition to check if the output of Filter Query is empty or not (wrong input from requester that makes the filter query to return empty) but this condition is always true while it should be false in the case of empty output (Job No in the CashAdvanceRequest is not matched with ProjectListTest).

 

Below is my flow of Get items with Filter Query

 

Get items - 1.PNG

 

Get items - 2.PNG

 

Thanks a lot for your help in advance.

 

Best regards,

 

Tan

1 ACCEPTED SOLUTION

Accepted Solutions
efialttes
Super User
Super User

Hi!

Sorry, I am probably missing something 😞

 

'Apply to ech' iterates' over 'GEt items' output, right? I mean, you assigned 'Get data from Job list' outputs as its input

THis 'Get items' also have a Filter Query, so you just get the items whose 'Job No' matches with the one provided.

I also assume the Condition is evaluating if 'Get items' results is empty, right?

If so, why are you placing it inside the 'Apply to each'. I would expect it outside, just after 'GEt items' and before the 'Apply to each'.

Now, the condition seems wrong. I would use either this condition

 

length(body('Get data from Job list')?['value'])

Operator: greater than

0

 

or this other condition

 

empty(body('Get data from Job list')?['value']))

Operator: equals

false

 

 

Please note 0 shall be added as text, false should be added as an expression.

I tend to use length() expression more, usually store it in a compose action block for troubleshooting since it provides nr of items, meaning you can make sure your filter query is working as expected

https://tahoeninjas.blog/2019/07/04/how-to-count-number-of-items-returned-by-sharepoint-getitems-act...

 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

4 REPLIES 4
efialttes
Super User
Super User

Hi!

Sorry, I am probably missing something 😞

 

'Apply to ech' iterates' over 'GEt items' output, right? I mean, you assigned 'Get data from Job list' outputs as its input

THis 'Get items' also have a Filter Query, so you just get the items whose 'Job No' matches with the one provided.

I also assume the Condition is evaluating if 'Get items' results is empty, right?

If so, why are you placing it inside the 'Apply to each'. I would expect it outside, just after 'GEt items' and before the 'Apply to each'.

Now, the condition seems wrong. I would use either this condition

 

length(body('Get data from Job list')?['value'])

Operator: greater than

0

 

or this other condition

 

empty(body('Get data from Job list')?['value']))

Operator: equals

false

 

 

Please note 0 shall be added as text, false should be added as an expression.

I tend to use length() expression more, usually store it in a compose action block for troubleshooting since it provides nr of items, meaning you can make sure your filter query is working as expected

https://tahoeninjas.blog/2019/07/04/how-to-count-number-of-items-returned-by-sharepoint-getitems-act...

 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

Dear @efialttes ,

 

Thanks a lot for your advice.

 

Yes you are correct. I should move the check empty output out of the Apply to Each.

 

Your 2nd solution works perfectly. Thanks a lot.

 

I also tried your first solution with 0 as "0" but this error came up

 

Get items - 4.PNG

 

Get items - 3.PNG

 

Hi!

I am afraid '0' is considered a stringby Flow editor

Please remove the single quotes leaving the digit alone and try again, or just remove it and assign the following expression instead

int('0')

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Hello @efialttes ,

 

Now it works perfectly for option 1 🙂

 

Thanks a lot again.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,458)