Power Apps | How to use the modern Radio control instead of Combo Box for Choice columns in Dataverse

Power Apps | How to use the modern Radio control instead of Combo Box for Choice columns in Dataverse

TL;DR When configuring the data card, make sure the DataField refers to the logical name and not the schema name of your choice column. Connect the radio control Items to the global choice using the Choices(...) formula and configure the DefaultSelectedItems to match the Value!

I'm currently working on improving an existing canvas app and tasked to change the input control for priority from 1-8 numeric values to High-Medium-Low.

The current current control was the classic radio control and I wanted to continue with radio buttons.


The classic radio control for the existing priority column


Instead of trying to change the existing choice field in Dataverse, I opted for creating a new.


The new global choice for Priority


So far - so good. Then I added the new choice column to the form, and Power Apps added a data card with the classic combo box.

The default control for the new priority choice column


I replaced this with the modern radio group control, and was immediately thrown into hours of tearing my hear off.

The modern radio control for the new priority choice column

I tried various options for getting the choice values into the radio control, but internet quickly led me to specify Choices( <global choice name> ). Internet also told me to add Value to the Fields to display. Value was the only available. Now, the three options were displayed correctly.

Next step was to connect the data card updates to the selected radio option. No big deal here, I simply specified <radio control>.Selected.Value.

This is when the fun started.

?? #1 - Why wasn't the selected value updated in Dataverse when form was saved?

?? #2 - Why was the current value in Dataverse added as a fourth option to the radio control?

It took me a few hours to figure out, and the internet wasn't exactly full of answers to these questions. Hopefully this article will help other people facing similar problems.


#1 - Updating Dataverse

??After hours of troubleshooting it turned out that my mistake was incorrect reference to the column in the DataField property of the priority data card. You need to use the logical name of the column and not the schema name. In my case, changing from "tek_Prioritet" to "tek_prioritet" solved the issue.

Here's how the working data card was finally configured.

Relevant data card properties:

?? DateField: tek_prioritet ?? Logical name of the choice column

?? Default: ThisItem.'S?kers prioritet' ?? Display name of the choice column

?? Update: radPrioritet.Selected.Value ?? The selected option* of the radio control

The data card properties


??*) When you connect the modern radio control to choice column in Dataverse you need to use the Value field, but when connecting to choice column in SharePoint you need to use the Title field!

The Fields property for the modern radio control

#2 - Selecting the default value

Figuring out what to use for the DefaultSelectedItems of the radio control was the problem that took me most time to figure out. Firstly, the naming of the property should be singular, given tha nature of a radio controlis that you select one of the options. Checkboxes is for multiple options. Anyway, neither of these worked:

? [ Parent.Default ]

? [ ThisItem.'S?kers prioritet' ]

? [ currentItem.'S?kers prioritet' ]

They all gave me this additional option, duplicating one of the three alternatives available.

The unwanted "additional" default option


??So, finally I found the hint in a comment in a not-so-relevant discussion in Microsoft Community; compare the default value with the Value field of the radio control's data items.

Here's how the working modern radio control was finally configured.

Relevant radio control properties:

?? Items: Choices(Prioritet) ?? The display name of the global choice

?? DefaultSelectedItems: [{Value: Parent.Default}] ?? Match the data with the Value* field

??*) For SharePoint, match the data with the Title field!

The mmodern radio control properties


Mengting Xie

SharePoint M365 Microsoft Power Platform Developer / Consultant

4 个月

Thank you for the great summary for how to use the modern radio control. I was stuck on the default value as well for some time. And for my scenario, I am using a field named "CancelType" for the radio control, then I need to replace the "Value" with "CancelType": Instead of using: [{Value: Parent.Default}]? I need to use: [{CancelType: Parent.Default}] I am also use the modern radio control to new form in the mean time, need to add the condition to only set the default value when the form is in edit mode. Otherwise in New form mode, the radio control will give an extra empty option. My final code for the radio in the Form: If(FormCanceledJourney.Mode=FormMode.Edit,[{CancelType:Parent.Default}])

要查看或添加评论,请登录

Petter Skodvin-Hvammen的更多文章

社区洞察

其他会员也浏览了