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
Avinash RaviAvinash Ravi 

Disable button after action

Hi, 

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.

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 

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

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

window.location.reload();

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.