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
syam11syam11 

trigger to delete contact records of an account , when account record deleted

Deepali KulshresthaDeepali Kulshrestha
Hi Harsha,

Greetings to you!

You don't have to write a trigger for this beacause when you delete a account automatically all contacts related to that account will be deleted.
And the same thing applied on opportunity which means when you delete a account automatically all opportunities related to that account will be deleted.

Account and Contact have both kind of relationship, they behave as a Master Detail even though they look like a Look up relation in UI.
You can create a contact without an account and such contacts are private so you won't be able to use them in reports and all. This shows that it is a Look up relation.
If you have created a contact with account and you delete that account then contact will be deleted, this shows that it is in Master-Detail relationship.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha.