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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

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