Mass Delete List View Button in Lightning!

      14 Comments on Mass Delete List View Button in Lightning!

Remember how I said I’d find a way to Mass Delete error records in lightning? Well here it is! (And shown in Lightning as well, you only need to use this for Lightning as you could use the JS Button for Classic)

Step 1 – Download this from Salesforce Labs (

Step 2 – Clone one of the VF Pages

Step 3 – Replace this in the cloned page with the custom object you want the button to live on

Step 4 – Make new button

Step 5 – Add it to the search results

Step 6 – Mass Delete!

Side note after writing this up I see in 2.9 someone added a VF page button that does the same thing.  WELL THE GOOD NEWS IS THIS WORKS WITH ANY OBJECT IF YOU HAVE ANY OTHER OBJECTS YOU WANNA ADD A MASS DELETE BUTTON TO 😉  The only difference is in editing the VF page you’d put the object API name where we put the DLRS object name and you’d most likely want to name the page something different.

14 thoughts on “Mass Delete List View Button in Lightning!

  1. Sachin

    Hello Dan,

    Hope you are doing well.
    This mass delete in lightning is great. But how to implement this for OpportunityLineItem?


  2. Nahwell

    Hi Dan,

    Can you provide the page code for one of these pages? I can’t seem to be able to install this package in my dev org.

    Thanks in advance!

  3. Joaquin Merlino

    Hi Dan,

    Man this was great! Just created the controller and the VF page using the github code, changed it to the custom object I needed and worked like a charm!

    Quick question, is there a way for that when I click the button, instead of taking me to a new page where I have to delete or cancel, it being done in a pop-up window in the list view/page where I clicked the button? Don’t have much or any coding experience in general, just an admin trying to learn here.


    1. Dan Post author

      Not sure honestly the only way I think you can do that is JS or a Lightning Component that has a JS Controller.

      1. Joaquin Merlino

        Never saw your reply, my bad! Will look into that option, looked around a little bit in the meantime and found that that was an option.


  4. Joaquin Merlino


    How would I be able to create a test class for this? I’m trying to push this to our Prod environment but can’t because of code coverage, so started writing the test class (based myself on what I could find online).


    1. Dan Post author

      For the VF page? Only the controller needs the test class and you use the standard controller so I’m not sure what test class you need.

  5. arun

    Great work, I used this code and worked like a charm. I need similar code for MassUpdate, specially having issue with updating lookup fields.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.