cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
ct_klein
Level: Powered On

Dynamically changing the bound entity of a list box on a canvas

I'm wondering if anyone has come across this issue. I have two radio buttons on a canvas app that I am attempting to control the values displayed within a list box.

RadioButtons.Items: ["SomeValueA","SomeValueB"]

The list box control should be getting reset whenever the value of the radio button changes.

UpdateContext({resetList: !resetList});
UpdateContext({resetList: !resetList});
Reset(lbListbox);

lbListbox.Reset: resetList

For the list box itself I have the following for Items:

Switch(
    RadioButtons.Selected.Value,
    "SomeValueA",
    Sort(
        EntityA.FieldName,
        Descending
    ),
    "SomeValueB",
    Sort(
        EntityB.'Some other field name',
        Descending
    )
)

The problem is when I select 'SomeValueA' the list box properly populates with the values from EntityA.FieldName but when I then select 'SomeValueB' from the radio buttons the list box blanks out with empty records. There appears to be items in the list box that I can scroll through and select but not see.

If I put two list boxes on the screen and set their Items event to the specific entity the values show up properly in both list boxes so I know the entity naming/field is correct.

I've tried it without the reset of the list box, I've tried it using collections made out of the entity records.

Has anyone come across this who maybe has a solution. I was going to try to put two list boxes on top of one another and either hide/show or bring to front the active list but that also doesn't want to work.

thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
GarethPrisk
Level 8

Re: Dynamically changing the bound entity of a list box on a canvas

Got this to work, but it was a bit finicky. The catch seemed to be giving the List a value-pairing table, instead of just a list of values.

First I collected the Option Sets from CDS, and added a column to indicate the source name, for reference. This could easily be combined into a single collection, and then filtered later but I was thinking simple.

ClearCollect(colOptionSet1,AddColumns(Choices('Ownership (Accounts)'),"appSource","Ownership"));
ClearCollect(colOptionSet2,AddColumns(Choices('Preferred Method of Contact (Accounts)'),"appSource","Preferred Method"));

Next added a Radio button identical to yours.

Then added a List control with Items equal to

If(
    Radio1.Selected.Value = "SomeValueA",
    colOptionSet1,
    Radio1.Selected.Value = "SomeValueB",
    colOptionSet2
)

You may need to use the right-side property pane to toggle between Value and "appSource" (from collections above), but this did allow me to toggle between two separate Option Set fields in a single list.

Patching/writing this back is gonna be another hurdle. 😝

View solution in original post

1 REPLY 1
GarethPrisk
Level 8

Re: Dynamically changing the bound entity of a list box on a canvas

Got this to work, but it was a bit finicky. The catch seemed to be giving the List a value-pairing table, instead of just a list of values.

First I collected the Option Sets from CDS, and added a column to indicate the source name, for reference. This could easily be combined into a single collection, and then filtered later but I was thinking simple.

ClearCollect(colOptionSet1,AddColumns(Choices('Ownership (Accounts)'),"appSource","Ownership"));
ClearCollect(colOptionSet2,AddColumns(Choices('Preferred Method of Contact (Accounts)'),"appSource","Preferred Method"));

Next added a Radio button identical to yours.

Then added a List control with Items equal to

If(
    Radio1.Selected.Value = "SomeValueA",
    colOptionSet1,
    Radio1.Selected.Value = "SomeValueB",
    colOptionSet2
)

You may need to use the right-side property pane to toggle between Value and "appSource" (from collections above), but this did allow me to toggle between two separate Option Set fields in a single list.

Patching/writing this back is gonna be another hurdle. 😝

View solution in original post

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (7,491)