You need to sign in to do that
Don't have an account?
Adam Rycroft
Help with List View Button Code
Hi,
I have this code to delete selected records from a List View. While it works fine, it always doubles the number of records that were deleted. Can someone help me to fix the line that tallies up the number of records successfully deleted?
I have this code to delete selected records from a List View. While it works fine, it always doubles the number of records that were deleted. Can someone help me to fix the line that tallies up the number of records successfully deleted?
{!REQUIRESCRIPT("/soap/ajax/9.0/connection.js")} var records = {!GETRECORDIDS( $ObjectType.Event )}; var taskRecords = {!GETRECORDIDS( $ObjectType.Task)}; records = records.concat(taskRecords); 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(); }