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

Parse JSON of a SharePoint Choice field, Problem If empty

Hi Community

I'm trying to parse some values from PowerApps to an Excel Table.
Most of it works, but when a choice field is empty it gives an error that it cannot find the value.
I tried the change the code in the Add a row into a table action like this:
If Secteur is empty -> " None Selected", else give me the value.

if(empty(items('Apply_to_each_2')?['Secteur']),"None Selected",items('Apply_to_each_2')?['Secteur']['Value'])

but it's not working. Any idea what i'm doing wrong here? 

Thanks a lot!
Bart

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @BClouded,

 

I think you are using the Secteur field instead of the Secteur Value field.

 

Can you try and use the expression below:

if(empty(items('Apply_to_each_2')?['Secteur/Value']), 'None Selected', items('Apply_to_each_2')?['Secteur/Value'])

 

View solution in original post

3 REPLIES 3
Expiscornovus
Super User
Super User

Hi @BClouded,

 

I think you are using the Secteur field instead of the Secteur Value field.

 

Can you try and use the expression below:

if(empty(items('Apply_to_each_2')?['Secteur/Value']), 'None Selected', items('Apply_to_each_2')?['Secteur/Value'])

 

View solution in original post

Thanks a lot, it's working now!
i didn't knew you could also reference to the value with /Value

Expiscornovus
Super User
Super User

To be clear, that's only the syntax for a choice field 🙂

 

Normally a choice field value would be something like below. So, basically you are retrieving the value property of the choice field value 😉

 

"Secteur": {
      "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
      "Id": 0,
      "Value": "A"
}

 

 

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!

Top Solution Authors
Top Kudoed Authors
Users online (2,387)