cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BenDonahue
Continued Contributor
Continued Contributor

Radio buttons Items set by a variable

The Goal

I am trying to populate the Items for a radio button by assigning the value of variable that contains the array of items to the Items of that radio button control.

 

The Situation

While I am able to get the required string into the variable with this code I put into a button:

BenDonahue_0-1619300230138.png

 

Set(strQGroupCode, "[" & """" & "Clinical Documentation" & """" & "," & """" & "Pediatric Asthma" & """" & "]");

 

and verify that the correct string value is being assigned by putting that variable into the Text property of a label:

BenDonahue_1-1619300348880.png

, when I put that same variable into the Items property of a Radio Buttons control, it does not work:

BenDonahue_3-1619300501859.png

 

The Ask

How do I populate the Items property of a radio button with dynamic values? These values come from a table and can either be supplied in the form shown, or by building it in the Items table with a couple LookUps. Dunno if that helps, but there it is. There may be other sources for getting this information, as I have not built that portion of the app yet, so I can be very flexible. The only requirement is that I take information entered by a user prior to this step to populate the Items for the radio button control.

 

The Thanks

Thank you for your time and help with this, for certain.

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User III
Super User III

Hi @BenDonahue ,

You cannot dynamically set a Variable as a String and then have it interpreted in another place as a Table - they are two different object types.

You can however do a Collection. Here is some test code I did - note the top bit is only to set the Variables - you would simply use yours. The Items of the drop-down is simply colMyDD (or whatever you want to call it)

UpdateContext(
    {
        var1: "Carrots",
        var2: "Tomatos",
        var3: "Onions",
        var4: "Cabbage",
        var5: "Lettuce"
    }
);
ClearCollect(
    colMyDD,
    {Value: var1},
    {Value: var2},
    {Value: var3},
    {Value: var4},
    {Value: var5}
)

You mentioned a Table however - if this is the case - the drop-down would be from a (if necessary) filtered list of this.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

2 REPLIES 2
WarrenBelz
Super User III
Super User III

Hi @BenDonahue ,

You cannot dynamically set a Variable as a String and then have it interpreted in another place as a Table - they are two different object types.

You can however do a Collection. Here is some test code I did - note the top bit is only to set the Variables - you would simply use yours. The Items of the drop-down is simply colMyDD (or whatever you want to call it)

UpdateContext(
    {
        var1: "Carrots",
        var2: "Tomatos",
        var3: "Onions",
        var4: "Cabbage",
        var5: "Lettuce"
    }
);
ClearCollect(
    colMyDD,
    {Value: var1},
    {Value: var2},
    {Value: var3},
    {Value: var4},
    {Value: var5}
)

You mentioned a Table however - if this is the case - the drop-down would be from a (if necessary) filtered list of this.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

BenDonahue
Continued Contributor
Continued Contributor

Beautiful.

 

I swear, with the assistance of generous persons like yourself (and many others), folks in the office think I'm actually good at this (I am the sum total of the dev department, so who's to know otherwise?)  🙂

 

This lesson has brought home something I learned, but did not truly grok, earlier in my Power Apps learning; this help you have provided has really crystalized some vital and intrinsic differences between variables and collections, particularly vis-à-vis their usage and application.


Thank you @WarrenBelz 

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (38,854)