cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BenDonahue
Skilled Sharer
Skilled Sharer

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
Super User

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
Super User

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.

BenDonahue
Skilled Sharer
Skilled Sharer

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
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 (1,951)