cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

Re: Disable button based off empty dropdown value

Awesome! I am happy to be able to help and very happy for your success!
JD2301 Helper II
Helper II

Re: Disable button based off empty dropdown value

Hi Wyotim,

 

I have a similar problem to the original post, I've followed you're instructions but I cant seem to get mine to work!

I have a radio button with "Pass" or "Fail". 
If "Fail" gets selected, it brings up a Comments Box, a dropdown list & a "send email notification" button as shown below.
The If statement I have used for these boxes to appear is if fail is selected is..
If("fail" in Radio5_33.Selected.Value, true) ...which works fine.

PAP3.pngHowever in the 'Assigned To dropdown', I have an option of "N/A".
If N/A is selected, I want the 'Send Email Notification' button to either be hidden or be disabled so it is unable to be pressed. Do you know what formula I need to use to get this to work please?

Thanks.

Super User
Super User

Re: Disable button based off empty dropdown value

@JD2301Assuming your dropdown is named 'Assigned To dropdown' and that you want the button to be disabled when "N/A" is selected, you would use the following code in the DisplayMode property of your button:

 

// Disable button if "N/A" is selected
If(
    'Assigned To dropdown'.Selected.Value = "N/A", 
    DisplayMode.Disabled, 
    DisplayMode.Edit
)


I noticed that your dropdown was blank in the picture, so if you want to incorporate that into the mix, the following should work (again in the DisplayMode property of your button):

 

// Disable button if dropdown is blank or "N/A" is selected
If( Or(IsBlank('Assigned To dropdown'.Selected.Value), 'Assigned To dropdown'.Selected.Value = "N/A"), DisplayMode.Disabled, DisplayMode.Edit )

If you instead want to make the button invisible, you would replace DisplayMode.Disabled with false and DisplayMode.Edit with true and put the formula in the Visible property of the button. You could also mix and match a bit, like if you want the button invisible when a blank value is in the dropdown but disabled when "N/A" is selected, but I digress. 

 

Let me know if that works for you. Otherwise, let me know and I'll be happy to help out until it does!

 

*edit for comment in second code snippet*

JD2301 Helper II
Helper II

Re: Disable button based off empty dropdown value

Hi Wyotim,

 

That is perfect thank you. 
I've set the button to be disabled if "Not Applicable" is selcted and I have changed the blank column to state "Please Select from List" and also managed to make the button disabled if this is chosen using the formula:
If(Dropdown6.Selected.Value = "Not Applicable", DisplayMode.Disabled, If(Dropdown6.Selected.Value = "Please Select From List", DisplayMode.Disabled))

Thanks for your help.

Highlighted
Super User
Super User

Re: Disable button based off empty dropdown value

@JD2301Awesome work! A couple suggestions about your code: it may be easier to read and change later if you use an Or statement instead of nesting If statements, especially because they have the same result. Something like:

 

// Disable button if "Not Applicable" or "Please Select From List" is selected
If(
    Or(Dropdown6.Selected.Value = "Not Applicable", Dropdown6.Selected.Value = "Please Select From List"), 
    DisplayMode.Disabled,
    DisplayMode.Edit
)

Also, you may test that your code works when selecting values other than "Not Applicable" and "Please Select From List" due to not explicitly having DisplayMode.Edit in there. It may not work properly. You may need to have something like (my addition to your code in bold):

 

If(
Dropdown6.Selected.Value = "Not Applicable",
DisplayMode.Disabled,
If(
Dropdown6.Selected.Value = "Please Select From List",
DisplayMode.Disabled,
DisplayMode.Edit
)
)

That stuff aside, I am happy you were able to get it working! 

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,860)