+ Start a Discussion
chaitu.gadam@hotmail.comchaitu.gadam@hotmail.com 

Initial term of field expression must be a concrete SObject: LIST<Account> at line 12 column 9

trigger AccountDuplicateTrigger on Account (before insert,before update)

{    

for(Account a:Trigger.New)    

{     List<Account> acc=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 duplicate Account');    

}

 

}

}

Best Answer chosen by Admin (Salesforce Developers) 
NTPNTP

Hello,

 

Since "acc" is a list you cannot directly access its field value.
You need to specify which record's field you need to access like

acc[0].Name.addError('you cannot create duplicate Account');   

 which gets the first record from the list.

 

Hope this will solve the issue. Please mark it as the solution if it does.

 

thanks

All Answers

NTPNTP

Hello,

 

Since "acc" is a list you cannot directly access its field value.
You need to specify which record's field you need to access like

acc[0].Name.addError('you cannot create duplicate Account');   

 which gets the first record from the list.

 

Hope this will solve the issue. Please mark it as the solution if it does.

 

thanks

This was selected as the best answer
chaitu.gadam@hotmail.comchaitu.gadam@hotmail.com
Thanks...its working.