Skip to main content
1 answer
  1. Jan 4, 2023, 11:50 AM

    Hi @Mandar Rahate

     

    Please check the below code

     

    trigger CheckAccountIdBeforeDelete on Contact (before delete) {

    // loop through all the contacts being deleted

    for (Contact c : Trigger.old) {

    // check if the AccountId is null

    if (c.AccountId == null) {

    // add an error to the contact

    c.addError('Please specify an AccountId before deleting this contact.');

    }

    }

    }

    Thanks

0/9000