1

I have custom button on standard detail page...I want to disable that button/gray out if my status picklist value is "Approved". Java script on button click

var newRecords = []; 
 var o = new sforce.SObject("Opportunity"); 
  o.id ="{!Opportunity.Id}"; 
   if ( o.Sub_Stage__c == 'Approved')
   {
     // disbale button
   }

Can some tell me how to do this..

5
  • possible duplicate of Need some help with a custom button or button override
    – eyescream
    Jan 23, 2013 at 5:45
  • You could try this.disabled = true but it would only disable on click. Alternatively JavaScript in sidebar or change RecordType via workflow, which changes page layout to one without the button. Jan 23, 2013 at 7:15
  • @eyescream I don't think it's duplicate - That is about customizing a managed custom button, this is about conditionally displaying it.
    – Benj
    Jan 23, 2013 at 16:15
  • @Benj still - trick described by Dr. Coleman could work. Or a sidebar JS injection since I've read in Spring '13 rel. notes they're going to kill the trick with JS injected into section headers...
    – eyescream
    Jan 23, 2013 at 16:31
  • Same trick could work, but the questions are different. Even if the same answer applies, I wouldn't expect most users to be able to find the information since it's a different use-case. Not such a big deal, though, either way.
    – Benj
    Jan 23, 2013 at 17:52

3 Answers 3

2

Being able to show/hide buttons on a page layout in response to the record field values was the subject of a cloudspokes challenge.

Here's a link to a solution (not mine!) that utilises the Salesforce sidebar to host the javascript that manipulates the button. Note that this won't work for Service Cloud Console as the sidebar doesn't get displayed:

http://www.tehnrd.com/show-and-hide-buttons-on-page-layouts/

0
0

I dont think it is possible to do so.

However, what you could possibly do is that, if you are using record types, add one more record type as "Approved". As the o.Sub_Stage__c field changes to Approved, change the record type to "Approved" (may need to write a trigger/workflow field update for this) and assign the page layout for this record type with the button hidden on this page layout.

May not be a straightforward solution but i hope this helps.

Here's an IDEA similar to your requirement:

-1

You can call a javascript function on status picklist's onChange event and in that function you can check wheter status value is 'Approved' and based on that you can disable that button/gray out that through CSS.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .