Hello!
I am building a PowerApp that is performing an API call, and the API call is returning a string that is either "left" or "right".
I also have a form in my PowerApp that includes a choice field, with the options "Left" and "Right".
I would like to automatically fill the choice with the corresponding value based on what the string says. How can I achieve this?
Hi , @hagru
Please try this:
Best Regards,
Yueyun Zhang
Thank you so much @v-yueyun-msft! That did the trick!
Just a little follow-up question for future reference and learning - are there any way to use the values of the choices instead of the indexes? Using the values makes it a bit easier on the eye.
Hi, @hagru
Thanks for your response!Your data source is Dataverse.
For example , if we Choices Set is like this, the first is "Left", second is "Right":
You can use this code in your DefaultSelectedItems:
If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance!
Best Regards,
Yueyun Zhang
I just edited my initial response.
The Items property is Choices(Direction). The two options are "Left" and "Right", they are both just text.
With your suggestion, it looks like the correct value is selected, but when submitting the form and looking at the table row in Dataverse, the Direction column is empty. The field is a Choice column.
Hi , @hagru
Thanks for your response! Can you show me your Combo box -items property in your side?
And do you mean you submit the Form , but the data do not save to your data source? And what's the data type of this field in your data source?
Best Regards,
Yueyun Zhang
Hello @v-yueyun-msft
That does select the right value in my Combobox, and it looks good, but when submitting the Form, the value is empty in the table row 😕
The choices are also set in the table column, which, so my Items property is Choices(Direction). The two options are "Left" and "Right".
Hi , @hagru
You can use this expression in your Combox - DefaultSelectedItems:
If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance!
Best Regards,
Yueyun Zhang
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional