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
Level: Powered On

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
Level: Powered On

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
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 377 members 5,742 guests
Please welcome our newest community members: