0

I have a listbox in PowerApps and I need to enable different dropdowns based on each selection of listbox item. I have one dropdown for each listbox items.

I tried the following code on my dropdowns, but it doesn't work and give error *, + is expected at this point in formula

below is the formula I wrote in DisplayMode of the dropdowns:

ForAll(ListBox1_1.SelectedItems, If(ThisRecord.Name="Offce ABC",DisplayMode.Edit,DisplayMode.Disabled));
MJ X
  • 8,506
  • 12
  • 74
  • 99

2 Answers2

1

There are a few ways of doing this depending on how your Dropdown Items are setup.

Assuming...

  1. There is somekind of relationship between the Items in the Listbox and the Items in each Dropdown
  2. Each Dropdown Items is a Collection (or a filtered part of a Collection)

...you can use the following logic for the DisplayMode property of the Dropdowns:

If(
    IsEmpty(
        Filter(lbox1.SelectedItems, Value in col1.field)
    ),
    DisplayMode.Disabled, 
    DisplayMode.Edit
)

Example in action:

enter image description here

SeaDude
  • 3,725
  • 6
  • 31
  • 68
  • Hi Thanks, for your Answer, could you please provide example, as my problem is that when I select a selection from listbox for example 1 and then I should say if listbox item 1 is selected enable dropdown1 which data source is coming from common data service. and when listbox item 2 is also selected it should enable another dropdown2 which is also data is coming from common data service. – MJ X Nov 24 '20 at 02:40
  • values in dropdown are totally different, from the values in listbox. – MJ X Nov 24 '20 at 02:42
1

Again, there are a few ways of doing this depending on how your Dropdown Items are setup.

Assuming now...

  1. There is NO relationship between the Items in the Listbox and the Items in each Dropdown

...you can use the following logic for the DisplayMode property of the Dropdowns:

If(
    Or(
        "1" in lbox1_1.SelectedItems,
        "2" in lbox1_1.SelectedItems,
        "3" in lbox1_1.SelectedItems
    ),
    DisplayMode.Edit, 
    DisplayMode.Disabled
)

...where "1", "2", etc. are the options in the Listbox Items property.

Example in action:

enter image description here

SeaDude
  • 3,725
  • 6
  • 31
  • 68
  • Hi, Thanks for the Answer, can you try populating data from a common data services, when I put your logic it doesn't work, it doesn't accept listbox1.SelectedItems and give error. but when I put listbox1.SelectedItems.Name the error goes out but the logic doesn't work – MJ X Nov 24 '20 at 14:17
  • I appreciate your help – MJ X Nov 24 '20 at 14:20
  • I want exactly what you did, the only thing is try using listbox source as common data service table/entity as a source – MJ X Nov 24 '20 at 14:25
  • I don't use CDS. You'll have to try different combinations on your own until it works. – SeaDude Nov 24 '20 at 15:50
  • I gived you app vote, but I can't accept it as answer, as it doesn't work with common data service source for the listbox – MJ X Nov 24 '20 at 22:19
  • Instead of `.SelectedItems` try `.Selected.Name`. – SeaDude Nov 25 '20 at 16:24