anusha(salesforce developer)

Thursday 5 January 2017

Deletion of account record should fail it has any contact records

 Deletion of account record should fail it has any contact records


trigger example6 on Account (before delete) {
    List<Account> accs=[select id,(Select id from Contacts) from Account where Id In:Trigger.Old];
    for(Account a:accs){
        if(a.contacts.size() > 0){
            a.addError('Account Record with contact can not be deleted');
        }
    }
}

1 comment:

  1. Hey there! Would you mind if I share your blog with my facebook group? There's a lot of people that I think would really enjoy your content. Please let me know. Thank youCollege Mathematics for Business test bank solutions manual

    ReplyDelete