+ Start a Discussion
Avinash RaviAvinash Ravi 

Disable button after action


I have this custom button that I'm using to Activate an order when clicked. Now I want this button to be hidden or grayed out when order status = Activated.


var c = new sforce.SObject("Order"); 

c.id = "{!Order.Id}"; 
c.Status = 'Activated'; 
c.Sync__c = true; 
result = sforce.connection.update([c]); 


Can someone help me out?
Virendra ChouhanVirendra Chouhan
Hi Avinash,

You can't disable button on the basis of status value but what you can do, you can check status first and if it is Activated then simply send alert message to user i.e. Order has already been activated.
Shivram SainiShivram Saini
Hi Avinash,

You have to override the detail page with a VF page. You just need to add a tag <apex:detail/> on that page and this will look like standard details page.
After that you can add JavaScript or jQuery to hide your button according to condition.