Delete Multiple Records Using Checkbox

Delete Multiple Records Using Checkbox In Lightning Component

Lightning Component

Delete Multiple Records Using Checkbox

In this post we are seeing that how to delete multiple records using checkbox in salesforce lightning components. also, showing error alert message, if any record dependent to other records.

Delete Multiple Records Using Checkbox

Prerequisites : basic understanding of Lightning Component. And apex Programming.
Step  1 : Create Server Side Apex Controller.


  • For this post i have use standard contact object.
  • See code comments.
Step 2 : Create Custom  Lightning Component.


  • In the above component code, we iterate all contact record with checkbox and store the record id in ui:inputCheckbox  text attribute on line number 58 [text=”{!}”} ].
  • See code comments.

  • See code comments.

  • See code comments.

  • After the winter 17 release you can  use the Lightning Design System style in Lightning Apps by extends=”fore:slds”.  The Salesforce Lightning Design System provides a look & feel that’s consistent with Lightning Experience. Use Lightning Design System styles to give your custom applications a UI that is consistent with Salesforce.

Delete Multiple Records Using Checkbox

Some Useful Resources : 


Delete Result Class

Lightning design style checkbox

Like our facebook page for new post updates.? & Don’t forget to bookmark this site for your future reference. ?

if you have any suggestions or issue with it, you can post in comment box  🙂


      • Hi ,

        When I am trying to put this component on a lighting page layout , I am getting this error message :

        “Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details. This page has an error. You might just need to refresh it. Action failed: c:DeleteWithCheckboxComponent$controller$doneWaiting [Cannot read property ‘style’ of null] Failing descriptor: {c:DeleteWithCheckboxComponent$controller$doneWaiting}”

        NOTE : with individual app it’s working fine

        can you please help me out on this


  • Hi

    I’m getting one issue, if there is only 1 contact;

    And we select, SelectAll option, then the 1 contact is not getting selected.

  • How to Add Multiple rows in a Lighnting Component

    If you click (+) a new row with all data will be populated


  • I have a question. Where is the event registered? As you are using the event to get the value in selectAll method. Can you let me know where the event was registered in component?
    if possible can you post the event code too.

    • Basically this event is Standard Lightning event binding with ‘event’ parameter in method it, means we are getting the value of that particulate Header checkbox which is selected and on the selection this ‘selectALl’ method will be fire, if it will be true then ‘event.getSource().get(“v.value”);’ return true if it false then it will be return false, simple 🙂
      Hops it helps

  • Cool. Thanks for the explanation.
    Suppose if the checkbox is selected then only we need to display the Delete Contact button as a separate component but not on the header. If checkbox is not selected then the Delete contact button should not be displayed.
    I mean to say instead of a button here can we create a panel component to display the Delete contact button depending on the checkbox selected or not instead of displaying it on the header everytime.

    Can you let me know how to do this and how to communicate between the components when doing this? Appreciate if you can post a code for this.

  • Hi..This doesn’t work with one record. component.find() is not working if their is only one record in the table. Try limiting the record to 1 and see if it works.

  • Hi Piyush,

    I need to check some records accordingly and i have to download only the checked records not all records. Is it possible you can share me some relevant code.

    Many thanks.

  • Hi Piyush,

    I need to query records from oportunity with checkbox next to each records. The functionality is, suppose I select 3 checkboxes i.e 3 records, I need to download detail pages of those 3 selected records by keeping a custom button. I need to achieve this functionality in lightning. Can you pls help with code.

  • I am doing something very similar but I am using my table to close Tasks. Unfortunately, I cannot get the “v.text” value (each individual Task ID) to come over to the controller and I am not sure what I am doing wrong.





  • @sfdcmonkey

    I need to workout a lot of tasks in lightning,where i can get list of tasks to be worked out.

    If you have any links or list of tasks kindly share with me.

  • Hi,

    Thank you so much for this example everything is good until I change ui buttons to lightning buttons, could you please suggest how can we use lightning buttons with this?

  • Thanks for the nice post. I try to update records from list view. Can you suggest me how to get number of records successfully updated and failed to update records in list view.

    Thanks in advance !!!


Leave a Reply