cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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 @Anonymous ,

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 @Anonymous ,

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.
Anonymous
Not applicable

Hi Kris,

 

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

 

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (3,340)