web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Disable a dropdown aft...
Power Apps
Answered

Disable a dropdown after a certain number of choices hav e been selected

(0) ShareShare
ReportReport
Posted on by 312

I have a dropdown menu with 10 options. I need the user to only be able to select three of them. I would like to disable the ability to pick additional options, and not clear the selections they have already made if they try. My combobox control is called "cmbJESeason" and I feel like the formula belwo should be close, but it's apparently not close enough. Any suggestions? Thanks in advance!!

 

If(    CountRows(cmbJESeason.SelectedItems) > 3,    Set(cmbJESeason.DisplayMode, DisplayMode.Disabled),    Set(cmbJESeason.DisplayMode, DisplayMode.Edit) )

Categories:
I have the same question (0)
  • JasonZF Profile Picture
    572 on at

    Is cmbJESeason the name of your dropdown control? You can't change a control's DisplayMode property directly via a behavior formula, however you can use a variable. Change the form's DisplayMode to a variable, such as varcmbJESeasonMode, then modify your above formula to: 

    If(    CountRows(cmbJESeason.SelectedItems) > 3,    UpdateContext({varcmbJESeasonMode:DisplayMode.Disabled}),    UpdateContext({varcmbJESeasonMode:DisplayMode.Edit}) )

    There is no need for a global variable for this, hence my change to UpdateContext() instead of Set().

  • KBeale Profile Picture
    312 on at

    Sorry, how do I change the form's display mode? 

  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @KBeale,

     

    To achieve this, you actually don't need a variable. To note: Variables also do not allow you to change property values from controls, this is done by writing code or conditional logic in that specific property. 

     

    This change is quite small, simply add the following code to the DisplayMode property of your dropdown / combobox:

     

    If(
     CountRows(Self.SelectedItems) >= 3, // feel free to choose between = or >=
     DisplayMode.Disabled,
     DisplayMode.Edit
    )

     

    What might be helpful UI/UX wise is adding a reset icon or button that would reset the combobox selection. This way the user can reset the combobox if they accidentally made a mistake during selection. The code on the icon/button OnSelect would be:

     

    Reset(cmbJESeason)

     

    If this solves your question, would you be so kind as to accept it as a solution.

    Thanks!

  • KBeale Profile Picture
    312 on at

    Hey @LaurensM! You solution worked perfectly, but a user just pointed out that the reset icon doesn't work when the user exits and returns to the app. It DOES work when they submit the form, navigate to other screens, and return to screen/form with the reset button. I am stumped! Do you have any idea why this could be? There doesn't seem to be any other problems with the form and/ or recognizing the record being edited.. Thanks in advance! 

  • KBeale Profile Picture
    312 on at

    I also started a new topic, so I can accept a solution on this specific issue https://powerusers.microsoft.com/t5/Building-Power-Apps/Reset-button-not-working-when-user-re-enters-the-form-to-edit/m-p/2174309#M544442

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard