Custom Mass Delete Board Button (Classic only)

This article describes the steps to create a custom mass delete button from a List View. The same feature is possible for Tasks also.





The steps
  1. Go to Setup | Create | Objects
  2. Click on the Name of the Custom Object
  3. Scroll down to the Buttons, Links & Actions section.
  4. Click on New Button or Link
  5. Name it as Delete
  6. Select the Display Type: List Button 
  7. Do check the option: Display Checkboxes (for Multi-Record Selection)
  8. Behaviour: Execute JavaScript
  9. Content Source: OnClick JavaScript
  10. Copy and paste the following code:
    {!REQUIRESCRIPT('/soap/ajax/29.0/connection.js')}
    try
    {
      var selectedRecords = {!GETRECORDIDS( $ObjectType.taskfeed1__Board__c )};
      if(selectedRecords.length<1)
        alert('Please Select at Least One Row !');
      else
      {
        userConsent = confirm(
            selectedRecords.length + 
            ' Record(s) will be Deleted. Continue ? '
          );
        if(userConsent == true)
        {
          delResult = sforce.connection.deleteIds(selectedRecords);
          if (delResult[0].getBoolean("success"))
          {
            alert('The Record(s) were Deleted Successfully.'); 
            window.location.reload();
          }
          else
            alert(
              'The Record(s) Could Not be Deleted. Error Message: ' + 
              delResult[0].errors.message
            );
        }  
      }
    }
    catch(e)
    {
      alert('The Action Could not be Completed. Error Message: ' + e);
    }
  11. Select Save
Now, we've to add it to the List View. Here you go:
  1. Go to Setup | Create | Objects
  2. Click on the Name of the Object
  3. Scroll down to Search Layouts section
  4. Click Edit next to List View Layout
  5. Move our new button from the Available Buttons to the Selected Buttons List
  6. Select Save
  7. Navigate to the Taskfeed Boards tab and select a List View.

Feedback and Knowledge Base