Skip to main content
bharath kumar mandava 님이 #Ask An Expert에 질문했습니다
trigger accountduplicatetrigger on account(before insert,before update)

 

{

 

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개
  1. 2014년 1월 23일 오전 10:45
    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
0/9000