function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Alter code to Mass Delete Tasks from User's "My Task" on SF Home Page

I installed a mass delete option for open activity related lists on contact and opportunity page layouts. What I'd really like is the ability to allow users to select/delete multiple tasks directly from their SF homepages "My Tasks" lists. Is it possible to alter the mass delete code to allow for this functionality? I see that the code is specific for each type of record the activities related list is attached to, so the code would need to delete tasks in general regardless of if they're related to an opportunity or contact, etc. (code pasted below.) Then there's just the matter of adding a mass delete button to the "My Tasks" list, provided that's possible. Has anyone tackled anything like this already?

var records = {!GETRECORDIDS( $ObjectType.Contact )};
//could this be changed to:  var records = {!GETRECORDIDS( $ObjectType.Tasks )}; ?

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'){
} else {
var es = res.getArray("errors");
if (es.length > 0) {
if (numFailed > 0){
alert("Failed: " + numFailed + "\nSucceeded: " + numSucceeded + " \n Due to: " + errors.join("\n"));
} else {
alert("Number of records deleted: " + numSucceeded);
Did you ever get this to work?