The following is sample code for a custom button which mass deletes records:-
// Include and initialize the AJAX Toolkit javascript library // {!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")} // Get the list of accounts that should be deleted. // Use the $ObjectType merge field to indicate the type of // record Ids that are expected. // var idsToDelete = {!GETRECORDIDS( $ObjectType.Lead)}; var deleteWarning = 'Are you sure you wish to delete ' + idsToDelete.length + ' leads—'; if (idsToDelete.length && (window.confirm(deleteWarning))) { // Delete the records, and pass a function into the call // so that the toolkit refreshes the current page // asynchronously when the call succeeds. // sforce.connection.deleteIds(idsToDelete, function() {navigateToUrl(window.location.href);}); } else if (idsToDelete.length == 0) { alert("Please select the leads you wish to delete."); }
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
The following is sample code for a custom button which mass deletes records:-
// Include and initialize the AJAX Toolkit javascript library
//
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
// Get the list of accounts that should be deleted.
// Use the $ObjectType merge field to indicate the type of
// record Ids that are expected.
//
var idsToDelete = {!GETRECORDIDS( $ObjectType.Lead)};
var deleteWarning = 'Are you sure you wish to delete ' +
idsToDelete.length + ' leads—';
if (idsToDelete.length && (window.confirm(deleteWarning))) {
// Delete the records, and pass a function into the call
// so that the toolkit refreshes the current page
// asynchronously when the call succeeds.
//
sforce.connection.deleteIds(idsToDelete,
function() {navigateToUrl(window.location.href);});
} else if (idsToDelete.length == 0) {
alert("Please select the leads you wish to delete.");
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.