trigger AccountTrigger2 on Account (before delete) {
if(Trigger.isBefore && Trigger.isDelete) {
List oppr = [SELECT ID, AccountId From Opportunity Where AccountId =: Trigger.old];
if(!oppr.isEmpty() && oppr.size() > 0 ) {
for(Account acc: Trigger.old ) {
acc.addError('You cannot delete this Account it has Opportunity related to it.');
}
}
}
}
why video is private
We will make them public soon.