function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NadiaNadia 

conditonally disable button on a layout

Hi I have a requirement to disable a 'Send Email' button on the Contact object if the 'opt out' field is true. Is there a way to do that?
thanks
werewolfwerewolf
You can't disable it.  You can make it disappear by changing the Contact to a different record type when that checkbox is checked (using a workflow field update) and then assigning a page layout without that button to contacts of that record type.  Or you can override the Send An Email button with an Scontrol which first checks if that checkbox is checked before redirecting to the normal Send An Email URL.
TheAskerTheAsker
I have the same requirement but for a text field, it should be enable when a specific checkbox is checked and inactive when the checkbox is unchecked. Your recommendation applies to this case too?
 
Thanks in advance!
werewolfwerewolf
Yes, the same recommendation applies.  Again, right now you can't make items on the edit page dynamically disable and enable themselves, unless you want to write that page in Visualforce.
NadiaNadia
thank you, using s-control works for us.