Created
November 21, 2012 09:25
-
-
Save cdeckert/4123959 to your computer and use it in GitHub Desktop.
Massdelete related List Records
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{!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