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
allen.zhangyilunallen.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);
    }
}
sailee handesailee hande
Hi allen.zhangyilun,

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. 
allen.zhangyilunallen.zhangyilun
thanks Sailee, yes, understand this, I'm just cannot fingure if this JavaScript solution is recommended or we have to move to VF solution.