{
for(account a:trigger.new)
{
list<account>acc=[select id from account where name=:a.name and rating=:a.rating];
if(acc.size()>0)
{
acc.NAME.addError('you cannot create the duplicate account');
}
}
}
2 risposte
Hi Bharath,
In your code, acc is a List<Account>. So you cannot directly access Name field from acc. Instead either you can use
acc[0].Name.addError('you cannot create the duplicate account');
OR
For(Account a : acc)
{
a.NAME.addError('you cannot create the duplicate account');
}
Thanking you,
Arun