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

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

Re: How to check if an object exists

 

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
Dual Super User
Dual Super User

Re: How to check if an object exists

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

Community Support Team
Community Support Team

Re: How to check if an object exists

 

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

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

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 Power Automate Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 89 members 5,534 guests
Please welcome our newest community members: