cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

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

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

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

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

Highlighted
Frequent Visitor

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

Hi Kris,

 

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

 

 

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,693)