Tuesday, December 6, 2016

Mass Delete | Delete from List View.


Step 1:-  Create a Mass Delete button on account object :


Setup->Accounts->Buttons, Links, and Actions



Then Click on New Button or Link Button.




Then add below code in your button and Click on Save .


{!REQUIRESCRIPT("/soap/ajax/9.0/connection.js")}
var records = {!GETRECORDIDS(  $ObjectType.Account )};
if(records[0] == null) {
alert("Please select at least one record.") 
}
else {
var errors = [];
var result = sforce.connection.deleteIds(records);
if (result && result.length) {
var numFailed = 0;
var numSucceeded = 0;
for (var i = 0; i < result.length; i++){
var res = result[i];
if (res && res.success == 'true'){
numSucceeded++;

else {
var es = res.getArray("errors");
if (es.length > 0){
errors.push(es[0].message);
}
numFailed++;
}
}
if (numFailed > 0) {
alert("Failed: " + numFailed + "\nSucceeded: " + numSucceeded + " \n Due to: " + errors.join("\n"));

else {
alert("Number of records deleted: " + numSucceeded);
}
}
window.location.reload();

}





Step 2:- Add button on List view

Setup -> Accounts->Account Search Layouts



Then click on edit to add button in  Account List view .




Add Mass Delete Button to Selected Buttons Click On Save.

Click On Accounts tab and click on Go button to go to list view.




you can see list of account Records and Mass Delete Button.

Select The Accounts which you want to Delete and Click Mass Delete Button.






No comments:

Post a Comment