Trigger-4
When we Create a new record on Account Object with different Names if name is existed in the Account object it show an error on Account Name.
trigger Trigger4 on Account (before insert) {
for(Account a:Trigger.New){
List<Account> accs=[select id, Name From Account Where Name=:a.Name];
if(accs.size()<0){
a.Name.addError('Sorry Account alredy exits');
}
}
}
// If you want to create a new record with existing record name, system show an Error message
If(accs.size()>0) should write instead of if(accs.size()<0)
ReplyDelete