cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sephiel
Level: Powered On

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
Community Support Team
Community Support Team

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.
3 REPLIES 3
Super User
Super User

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!

 

 

Community Support Team
Community Support Team

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.
Sephiel
Level: Powered On

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

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 364 members 4,395 guests
Recent signins:
Please welcome our newest community members: