Tag Archives: SFDC

Salesforce – Field Update on Button Click Using Javascript

Here in below example, there is a custom field Active__c in Contact object. On a button click want to update Active__c field status to true.

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
 
if(confirm("Do you want to active this Contact?") == true) 
{
    var objC = new sforce.SObject("Contact");        
        objC.Id = '{!Contact.Id}';
        objC.Active__c = true;
        var result = sforce.connection.update([objC]); 
        window.location.reload();
}