How to trigger to delete account record when contact record gets deleted?

How to trigger to delete account record when contact record gets deleted?

First exception on row 0 with id 0011100000R5Gf0AAF; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 0031100000QId7U) is currently in trigger deleteAccountRecord, therefore it cannot recursively delete itself: []” I have tried using “After Insert” but DelAccountRecordList returns null with no records.

What happens if you delete one contact on an account?

Account and contact has one to many relationship.As per your logic,if you delete one Contact it would relate the Account which is subsequently going to delete all the Contacts with that Account (standard functionality) which means you have lost Contact data. Can you pls explain what is the use case here ?? Thanks for the reply.

Is there a way to recover a deleted contact?

Important: You can’t recover a contacts subfolder folder that’s been permanently deleted. You can recover a deleted subfolder folder (with all of its contacts) if it’s still in your Deleted Items folder. When you delete a contact, it’s moved to the Deleted Items folder in your mailbox just like a deleted email message.

What happens when you delete an account in Salesforce?

This is happening because when you Delete the Account, through trigger ,it is trying to delete the related Contacts as well as per standard Functionality of salesforce. As you are deleting the Contact through UI,it is throwing error. Also,I don’t understand the use case here.

What to do if someone tries to delete your apex account?

I need to write a trigger in which if an account that has related contacts and the user tries to delete that account it throws you an error..

How do you delete a contact record in CRM?

Navigate to CRM > Contacts and retrieve the contact record that you want to delete. In the contact record, scroll down and click the Delete button. Please note that you may lose information such as referral partner records or other data that you might want to keep.