function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sateesh mSateesh m 

Initial term of field expression must be a concrete SObject: LIST<Account>

Please find the below trigger ...getting below error " Initial term of field expression must be a concrete SObject: LIST<Account>"

Could you please let me know what is this error ?

trigger AccountDuplicate on Account (before insert, before update)
{
    for(Account a:Trigger.new)
    {
        List<Account> acc =[select id, Name from Account where Name=:a.Name];
        if(acc.size()>0)
        {
        acc.Name.addError('You Cannot Create the Duplicate Account');
        }
    }
}
Best Answer chosen by Sateesh m
Suneel#8Suneel#8
In the below line you should be using a instead of acc as acc is a list of accounts not a specific account.

acc.Name.addError('You Cannot Create the Duplicate Account');

All Answers

Suneel#8Suneel#8
In the below line you should be using a instead of acc as acc is a list of accounts not a specific account.

acc.Name.addError('You Cannot Create the Duplicate Account');
This was selected as the best answer
Sateesh mSateesh m
Thanks Suneel,  Now it's working fine.

a.Name.addError('You Cannot Create the Duplicate Account');


 
Suneel#8Suneel#8
OK great.Please mark this as solved