0

i have a custom button on Quote detail page, on click of this button i am calling a function through javascript.

On load of this Quote detail page, If the Quote status is 'Accepted' then i need to disable this button. if the Quote status is something else then i need to enable this button. On click of the button(when enable) i want to change the Quote status to 'Accepted'.

i don't know how to achieve this. i tried doing it with javascript but it doesn't work for me.

below is my javascript code of the custom button.

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

if("{!Quote.Status}" != "Accepted"){
var QuoteId = "{!Quote.Id}";
alert(QuoteId);
sforce.apex.execute("GenerateXMLOnQuoteAccept","generateXML",{QId:QuoteId});
alert('done');
}

button setting: Behavior: Execute Javascript
Content Source: Onclick Javascript

1 Answer 1

1

There is no way to disable button but you can extend your JavaScript code to notify user like:

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
if("{!Quote.Status}" != "Accepted"){
var QuoteId = "{!Quote.Id}";
alert(QuoteId);
sforce.apex.execute("GenerateXMLOnQuoteAccept","generateXML",{QId:QuoteId});
alert('done');
}
else
{
alert('Error:Quote is already accepted');
}
2
  • any work around? Oct 4, 2016 at 9:24
  • 1
    You can go for a solution based on record type and page layouts. There would be two layouts one with button and one without button. On first click of button you can change record type that will send user to replica record type which do not contain that button. Oct 4, 2016 at 9:30

You must log in to answer this question.

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