trigger contaccdelete on Contact (before delete) {
list<id> accounts = new  list<id>();
    for (contact c : trigger.old){
       list<account> accs = [select  id from account where id in :accounts];
        delete accs;

===================== I got the error

Validation Errors While Saving Record(s) There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger contaccdelete caused an unexpected exception, contact your administrator: contaccdelete: execution of BeforeDelete caused by: System.DmlException: Delete failed. First exception on row 0 with id 0017F00000Aw2dyQAB; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 0037F000007zQ1f) is currently in trigger contaccdelete, therefore it cannot recursively delete itself: []: Trigger.contaccdelete: line 10, column 1".

1 Answer 1


When you delete an Account, corresponding contacts are deleted. So in this case, from within Contact delete trigger, you are deleting Accounts, which in turn tries to delete the same contact and hence resulting in that error.

You could move your trigger to after delete, and try.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .