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

Handling if a key does not exist in JSON Parse

I am working with some data from an API where need to look at some values from a JSON file. I am using the apply each and then using compose to get the values of an array. Unfortunately, some of the keys I am looking for do not exist so Power Automate is failing. 

 

Is there a way that if it fails that it returns a null value??? 

 

In the Inputs for the compose I am using variables('trackerRows').cells[7].value).
 
The problem is on some of the elements, value does not exist as a field in the json for some of the values. Is there a way to ignore this somehow or should I take a different approach?
 
So Microsoft flow returns a message like this:
 
InvalidTemplate. Unable to process template language expressions in action 'ExecutiveSponsor' inputs at line '1' and column '2906': 'The template language expression 'variables('trackerRows').cells[9].value' cannot be evaluated because property 'value' doesn't exist, available properties are 'columnId'. Please see https://aka.ms/logicexpressions for usage details.'
 
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Handling if a key does not exist in JSON Parse

Hi @dcafiero,

 

You could use Parse JSON action to parse these data, then you could use dynamic content in next actions.

I use an instance to explain, I have a JSON as below, the Age property is not required, some item does not contain it. Then put the "Name" array into Apply to each action, if the Age property does not exist in the item, it will return null:

Annotation 2020-06-18 142425.jpg

 

Best Regards,
Community Support Team _ Lin Tu
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
Highlighted
Community Support
Community Support

Re: Handling if a key does not exist in JSON Parse

Hi @dcafiero,

 

You could use Parse JSON action to parse these data, then you could use dynamic content in next actions.

I use an instance to explain, I have a JSON as below, the Age property is not required, some item does not contain it. Then put the "Name" array into Apply to each action, if the Age property does not exist in the item, it will return null:

Annotation 2020-06-18 142425.jpg

 

Best Regards,
Community Support Team _ Lin Tu
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
Regular Visitor

Re: Handling if a key does not exist in JSON Parse

@v-litu-msft,

 

I will try what you mentioned. 

 

I was able to handle this for the time being by in my compose adding an if statement if it doesn't contain a value to return null.

 

if(contains(variables('trackerRows').cells[9], 'value'), variables('trackerRows').cells[9].value, 'null')

Helpful resources

Announcements
Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Top Solution Authors
Top Kudoed Authors
Users online (5,751)