Trigger to prevent creation of duplicate accounts
//For fetching existing account names
map<Id,Account> existingAccountMap = new map<Id,Account>([Select Id, Name, Rating From Account]);
for(Account a : Trigger.new){
if(a.name = existingAccountMap.get(a.Id).Name){
a.adderror('You cannot create a dulplicate account');
}
}
}
No comments:
Post a Comment