You need to sign in to do that
Don't have an account?
allen.zhangyilun
If this button is an s-control and recommended by Salesforce?
Attached is a button in contact with to change the status of contact, if this solution is recommended by Salesforce, since dml direct from the button.
{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")}
var con = new sforce.SObject("Contact");
con.Id = '{!Contact.Id}';
con.Contact_Status__c = 'Deactivated';
var result = sforce.connection.update([con]);
if('{!Contact.Contact_Status__c}' == 'Deactivated') {
alert('Contact has been already deactivated');
} else {
if(result[0].getBoolean("success"))
{
alert('Contact is deactivated');
window.location.reload();
}
else{
alert('Error : '+result);
}
}
{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")}
var con = new sforce.SObject("Contact");
con.Id = '{!Contact.Id}';
con.Contact_Status__c = 'Deactivated';
var result = sforce.connection.update([con]);
if('{!Contact.Contact_Status__c}' == 'Deactivated') {
alert('Contact has been already deactivated');
} else {
if(result[0].getBoolean("success"))
{
alert('Contact is deactivated');
window.location.reload();
}
else{
alert('Error : '+result);
}
}
S-controls have been superseded by Visualforce pages. After March 2010 organizations that have never created s-controls, as well as new organizations, won't be allowed to create them. Existing s-controls will remain unaffected, and can still be edited. Salesforce recommends that you move your s-controls to Visualforce.