Monday, January 27, 2014

Multiple Records update on button Click(java script)


In the Account list view page add the button and the type should be java script add the below code to update multiple accounts

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
var url = parent.location.href; //string for the URL of the current page
var records = {!GETRECORDIDS($ObjectType.Account)};
var updateRecords = [];

if (records[0] == null) {
alert("Please select at least one record to update.");
} else {
for (var a=0; a<records.length; a++) {
var update_Account = new sforce.SObject("Account");
update_Account.Id = records[a];
update_Account.Status = "Unqualified";
updateRecords.push(update_Account);
}
result = sforce.connection.update(updateRecords);
parent.location.href = url;
}

No comments:

Post a Comment