cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
acummings
Frequent Visitor

Creating a dropdown from a complex object returned from API / JSON [object Object]

Hi,

 

I'm building a basic app using an API backend (asp.net). The powerapp should make api calls for each action that takes place. 

 

I am having trouble accessing the values within my JSON response which I have currently set up with an on-premise gateway.

 

I have tested the API call on swagger and on the test page of 'Custom Connectors'. The data is being returned, I just don't know how to display it. I've posted some images of the problem, the returned JSON and the associated error, which reads:

 

"Warning: The column produced by this rule are all nested tables and/or records, however the property expects at least some columns of simple values (such as text, or numbers)"

 

image1.png

See the JSON response below. I would like to just display the 'text' value for each risk, and ideally store the 'id' within the collection for submission.

image2.png

 

Any help would be greatly appreciated, thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @acummings ,

Could you please share a bit more about your scenario?

Do you want to display the 'text' value for each risk within the Dropdown box, but store the 'id' value back to your data source?

 

Based on the formula that you mentioned, I think there is something wrong with it. The IncidentReportAPI.GetAllRisks().result.items formula would return a Object Array, within each object, it also includes a nested object.

Currently, within PowerApps app, we could not display a Object Array with nested object directly within a Dropdown box.

 

As an alternative solution, I think the ForAll function could achieve your needs, please consider take a try with the following workaround:

Set the Items property of the Dropdown box to following:

ForAll(
        IncidentReportAPI.GetAllRisks().result.items,
        {
          Text: risk.text,
          Id: risk.id
        }
)

use the Text attribute as DisplayColumn value within the Dropdown box, then text value for each risk could be displayed in your Dropdown box.

 

When you want to reference the selected text value or id value from above Dropdown box, please use the following formula:

Dropdown1.Selected.Text
Dropdown1.Selected.Id

 

If you want to bind the above Dropdown box to a field in your Edit form, please set the Update property of the field in your Edit form to following:

Dropdown1.Selected.Id

then when you save your form data, the Id value of the selected text within the Dropdown box would be saved back to your data source.

 

Best regards,

Community Support Team _ Kris Dai
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
v-xida-msft
Community Support
Community Support

Hi @acummings ,

Could you please share a bit more about your scenario?

Do you want to display the 'text' value for each risk within the Dropdown box, but store the 'id' value back to your data source?

 

Based on the formula that you mentioned, I think there is something wrong with it. The IncidentReportAPI.GetAllRisks().result.items formula would return a Object Array, within each object, it also includes a nested object.

Currently, within PowerApps app, we could not display a Object Array with nested object directly within a Dropdown box.

 

As an alternative solution, I think the ForAll function could achieve your needs, please consider take a try with the following workaround:

Set the Items property of the Dropdown box to following:

ForAll(
        IncidentReportAPI.GetAllRisks().result.items,
        {
          Text: risk.text,
          Id: risk.id
        }
)

use the Text attribute as DisplayColumn value within the Dropdown box, then text value for each risk could be displayed in your Dropdown box.

 

When you want to reference the selected text value or id value from above Dropdown box, please use the following formula:

Dropdown1.Selected.Text
Dropdown1.Selected.Id

 

If you want to bind the above Dropdown box to a field in your Edit form, please set the Update property of the field in your Edit form to following:

Dropdown1.Selected.Id

then when you save your form data, the Id value of the selected text within the Dropdown box would be saved back to your data source.

 

Best regards,

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

Hi Kris,

 

Yes, this is exactly what I needed, thank you.

 

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (17,596)