You need to sign in to do that
Don't have an account?
tkline
Expire Contract Button
Hey guys-
This is probably a simple solution but I couldn't find the code anywhere (checked the salesforce cookbook and code share). I'd like to make a button that is displayed on the Contract layout that when clicked changes the status to "Expired".
This would essentially be the same thing as the standard Activate button, only it expires contracts instead.
Any help would be appreciated. Thanks guys!
Hello tkline,
This might help you..
Create a Class something like this...
global class ContractStatusupdate{
webService static String updatecontractStatus(Id conid) {
String results;
Contract c = [Select Id, Status from Contract where id = :conid limit 1];
c.Status = 'Expired';
update c;
results = 'Status Updated';
return results;
}
}
Then Create a custom button called "Expire" on contracts and choose onclick Javascript... copy paste the following code
{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}
var idToUpdate= '{!Contract.Id}';
var strResult = sforce.apex.execute("ContractStatusupdate","updatecontractStatus",{conid:idToUpdate});
//first parameter: Name of class, Second parameter: Method name and third parameter: Parameters of the above class method
alert(strResult);
window.location.reload();
Thanks, Sam
Hi,
You want to hide a button when the stage is changed or at particular stage then we have to write a visual force page and override the view page of that object the below code will expalin how to hide the button in the Lead related list view at particular stage.