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

How to get proper condition result checking an empty array object?

Hello,

 

I am trying to set up an automatic email detailing planner tasks that are not complete in a particular bucket. I have gotten as far as to get emails working properly, but I need to add a condition to check whether there are any open tasks (I don't want the flow to send an email if there are no tasks to complete.) So, I confirmed that the filter array is outputing "[]" but when it passes through my condition it always comes back as true.

 

Capture.PNGCapture2.PNG

If I'm understanding other examples, what would be best is to use @empty to check for an empty object. But since there is no longer the ability to work in advanced mode in conditions, I don't know how to accomplish this. 

 

What I need is to check that if this filter array's output is not null (true), then it will send the reminder email. If it is null (false), don't send any email.

 

Appreciate any insight. Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: How to get proper condition result checking an empty array object?

Hi @Sephiel,

 

I almost agree what @yashag2255  suggested.

 

Please take a try with length function, I have tested it likes below for your scenario, and it is working fine.

1.PNG

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
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

3 REPLIES 3
Highlighted
Dual Super User III
Dual Super User III

Re: How to get proper condition result checking an empty array object?

Hi @Sephiel 

 

There are two ways that I can think of for doing this. 

1. Get the length of the array using the length(array) function and compare if it is 0

2. Initialise a boolean variable and check if the array is empty. 

Please see the screenshot and expressions below:twt.png

You can use any one of the method. 

For the boolean variable the expression used is: 

if(empty(variables('dd')),true,false)

Here "dd" is an array variable I initialised in the flow. This expression sets the value of the boolean variable to true if the array is empty and false if it is not. You can use this variable output in firther condition actions to complete the flow. 

Directlty in the condition, the expression used is :

length(variables('dd'))

This checks the length of the array and if it is 0 then go to Yes branch and if not zero goes to No branch 

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

 

 

Highlighted
Community Support
Community Support

Re: How to get proper condition result checking an empty array object?

Hi @Sephiel,

 

I almost agree what @yashag2255  suggested.

 

Please take a try with length function, I have tested it likes below for your scenario, and it is working fine.

1.PNG

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
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

Highlighted
Helper I
Helper I

Re: How to get proper condition result checking an empty array object?

Using the length function worked great. Mabel, using

length(body('Filter_array_2')) 

worked perfectly.

 

Thank you both!

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Top Kudoed Authors
Users online (8,144)