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

Author - 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):

{
!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")
}
var rec = new sforce.SObject("Contact");
rec.Id = "{!Contact.Id}";
rec.IsActive= 'true’;
var result = sforce.connection.update([rec]);
window.location.reload();

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 salesforce@webners.com

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

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