Sunday, September 11, 2016

How to Update a field when a button is clicked on record level ?

Step 1.  Create  a custom button (name it as "Update Field") and select content source as  "Onclick Javascript "

Step 2 . Paste below code in it

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 

var newRecords = [];
var c = new sforce.SObject("Account"); 
c.id ="{!Account.Id}";
c.NumberofLocations__c = '400';
newRecords.push(c); 
result = sforce.connection.update(newRecords);
window.location.reload();

Note: - Here NumberofLocations__c is a custom field

Step 3 . Open any account record 
Before Clicking UpdateField Button 



After Clickling UpdateField Button 
You will find value of Number of locations is changed from 6 to 400 as below 


No comments:

Post a Comment