1 answer
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