Salesforce | Change value of an object’s field on button click and reload page

| By Webner

We can change the value of an object’s field on button click by using javascript like this (and this will also reload the page):

var rec = new sforce.SObject("Contact");
rec.Id = "{!Contact.Id}";
rec.IsActive= 'true’;
var result = sforce.connection.update([rec]);

In this code we are assuming that we want to change the status of the Contact object. You can associate this code to a button in Setup area

Webner Solutions is a Software Development company focused on developing CRM apps (Salesforce, Zoho), LMS Apps (Moodle/Totara), Websites and Mobile apps. If you need Salesforce customization, App development or any other software development assistance please contact us at

Leave a Reply

Your email address will not be published. Required fields are marked *