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
{!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();
}
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 add button in Account List view
Step 3:- Finally ready to use :-
Reference document which i followed :-
1) https://help.salesforce.com/HTViewHelpDoc?id=links_useful_custom_buttons_mass_delete.htm
You can install custom buttons from the Mass Delete app at http://sites.force.com/appexchange.
Amit Chaudhary
Mass Delete Salesforce List Views within few clicks. Know more - https://bofc.io/manage-list-views/how-to-delete-multiple-list-views-in-few-clicks
ReplyDelete