Skip to content

Instantly share code, notes, and snippets.

@cdeckert
Created November 21, 2012 09:25
Show Gist options
  • Save cdeckert/4123959 to your computer and use it in GitHub Desktop.
Save cdeckert/4123959 to your computer and use it in GitHub Desktop.
Massdelete related List Records
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")}
var records = {!GETRECORDIDS( $ObjectType.Region_Holiday__c )}; // API Record Name
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("Fehler: " + numFailed + "\nErfolgreichgelöscht: " + numSucceeded + " \n durch: " + errors.join("\n"));
} else {
alert("Datensätze gelöscht: " + numSucceeded);
}
}
window.location.reload();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment