cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
drake
Advocate II
Advocate II

How do you determine if a property exists or not in a JSON object with Power Automate Desktop?

I am using Set Variable to get the value of a JSON object property.  Sometimes this property isn't present, however, and the desktop flow stops with an error.  I tried wrapping the Set Variable action in an "On block error", with the "Continue flow run" option set (screenshot below), and then checking for empty string afterward.  The "On block error" doesn't work, however, and the Set Variable action's error stops the desktop flow.  

 

I've tried a few other things, but none have worked so far.  Is it possible to determine if a property exists or not in a JSON object with Power Automate Desktop?  

 

drake_0-1625769952983.png

 

1 REPLY 1
tkuehara
Solution Specialist
Solution Specialist

Hi @drake 

 

Yes, you can try using "If contains". For example, in the object below:

tkuehara_0-1625772424638.png

tkuehara_3-1625772621003.png

 

The "If contains Data7" will find the element:

tkuehara_1-1625772477919.png

If I search for a "Data8" (non-existing element), it will return "No":

tkuehara_2-1625772574924.png

 

You could also try a parse of the entire json, but you need to convert your object to string before parsing. If the parse action returns 0 matches, then you don't have that property in your json.

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.

Users online (1,151)