cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
String
Regular Visitor

How to check if an object exists

I need to check if an object exists.

Example Compose:

 

[
  {
    "category5": true
  }
]

"category5" could be any number from 1-6 e.g "category2" etc..

 

 

How can I check the Output of Compose to see which category is set to true? I have tried to loop through an array of categories 1-6 and checking if empty, but I keep getting an error because the only category that exisits is boolean.

 

Error: Unable to process template language expressions for action 'Condition' at line '1' and column '2639': 'The template language function 'empty' expects its parameter to be an object, an array or a string. The provided value is of type 'Boolean'. Please see https://aka.ms/logicexpressions#empty for usage details.'

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

 

Hi @String ,

 

Please try to use the following configuration.

First store the expected categories in an array variable, then traverse the Output to see if the expected category exists.

You could download the .zip file from the attachment and import it as a new Flow to test.

Hope it helps.

 

Best Regards,

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

2 REPLIES 2
RezaDorrani
Dual Super User II
Dual Super User II

Hi @String 

 

[
  {
    "category5": true
  }
]

The above Compose action generates an array

 

Expressions can be

empty(outputs('Compose'))  - which will return False since array is not empty
length(outputs('Compose')) - will return 1 since the array has 1 item
 
 
If you want to check which category is true
you would have to parse through each category
 
you can run outputs('Compose') in a for loop in Flow
 
and then within loop
do
 
item()?['category1']
item()?['category2']
....
item()?['category3']
 
and check to see if it is set to true
equals(item()?['category1'],true) etc.
 

Regards,

Reza Dorrani

 

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

v-bacao-msft
Community Support
Community Support

 

Hi @String ,

 

Please try to use the following configuration.

First store the expected categories in an array variable, then traverse the Output to see if the expected category exists.

You could download the .zip file from the attachment and import it as a new Flow to test.

Hope it helps.

 

Best Regards,

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

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.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

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.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (2,061)