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
Board salesforceBoard salesforce 

Account Related contacts Should be Deleted with Custom Button

Hi Techie's,

Here is one requirement ,i need a custom delete button on the account related contacts ,when i click on the delete button whole the records should be deleted without selection of contact records.Please help me out 

Thanks ,
SandhyaSandhya (Salesforce Developers) 

For List view of contacts, I have created custom delete button.Is this the same you are looking for?

1.Go to Setup | Create | Objects
2.Click on the contact
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 [Do check the option: Display Checkboxes (for Multi-Record Selection)]
7.Behaviour: Execute JavaScript
8.Content Source: OnClick JavaScript
  var selectedRecords = {!GETRECORDIDS( $ )};
    alert('Please Select at Least One Row !');
    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.'); 
          'The Record(s) Could Not be Deleted. Error Message: ' + 
  alert('The Action Could not be Completed. Error Message: ' + e);

10.Hit Save
Now, we've to add it to the List View. Here you go:
11.Go to Setup | Create | Objects
12.Click on the Name of the Object
13.Scroll down to Search Layouts section
14.Click Edit next to List View Layout
15.Move our new button from the Available Buttons to the Selected Buttons List
16.Hit Save

Hope this helps you!

Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
Thanks and Regards