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
BegginerBegginer 

Could anyone help me with the issue?Error: customwrappersample Compile Error: Initial term of field expression must be a concrete SObject: List<Account> at line 8 column 5

Controllerclass

public class customwrappersample 
{
public List<customerwrapperclass> lstwrapper {get;set;}
public void LoadData()
{
lstwrapper = new list<customerwrapperclass>();
List<Account> lstaccounts = [select id, name, rating, phone, billingcity from account limit 10];
if(!lstaccounts.isEmpty)
 {
     for(account acc : lstaccounts)
     {
    
     lstwrapper.add(new customerwrapperclass(acc , false));
     
     }
 
 }
List<contact> lstcontacts = [select id, firstname, lastname, phone,email, mailingcity from contact limit 10];
if(!lstcontacts.isEmpty)
 {
     for(contact con: lstcontacts)
     {
     
     lstwrapper.add(new customerwrapperclass(con,false));
     
     }
 
 }
 List<lead> lstleads = [select id, firstname, lastname, phone,email, city from lead limit 10];
if(!lstleads.isEmpty)
 {
     for(lead ld: lstleads)
     {
     
     lstwrapper.add(new customerwrapperclass(ld,false));
     
     }
 
 }

}

}

 
Best Answer chosen by Begginer
Dilip_VDilip_V

Begginer ,

You missed () at line nmber 8.
try this 
public class customwrappersample 
{
public List<customerwrapperclass> lstwrapper {get;set;}
public void LoadData()
{
lstwrapper = new list<customerwrapperclass>();
List<Account> lstaccounts = [select id, name, rating, phone, billingcity from account limit 10];
if(!lstaccounts.isEmpty())
 {
     for(account acc : lstaccounts)
     {
    
     lstwrapper.add(new customerwrapperclass(acc , false));
     
     }
 
 }
List<contact> lstcontacts = [select id, firstname, lastname, phone,email, mailingcity from contact limit 10];
if(!lstcontacts.isEmpty)
 {
     for(contact con: lstcontacts)
     {
     
     lstwrapper.add(new customerwrapperclass(con,false));
     
     }
 
 }
 List<lead> lstleads = [select id, firstname, lastname, phone,email, city from lead limit 10];
if(!lstleads.isEmpty)
 {
     for(lead ld: lstleads)
     {
     
     lstwrapper.add(new customerwrapperclass(ld,false));
     
     }
 
 }

}

}
Let me know if you have any issues.

Mark it as best answer if it works.

Thanks.
 

All Answers

Dilip_VDilip_V

Begginer ,

You missed () at line nmber 8.
try this 
public class customwrappersample 
{
public List<customerwrapperclass> lstwrapper {get;set;}
public void LoadData()
{
lstwrapper = new list<customerwrapperclass>();
List<Account> lstaccounts = [select id, name, rating, phone, billingcity from account limit 10];
if(!lstaccounts.isEmpty())
 {
     for(account acc : lstaccounts)
     {
    
     lstwrapper.add(new customerwrapperclass(acc , false));
     
     }
 
 }
List<contact> lstcontacts = [select id, firstname, lastname, phone,email, mailingcity from contact limit 10];
if(!lstcontacts.isEmpty)
 {
     for(contact con: lstcontacts)
     {
     
     lstwrapper.add(new customerwrapperclass(con,false));
     
     }
 
 }
 List<lead> lstleads = [select id, firstname, lastname, phone,email, city from lead limit 10];
if(!lstleads.isEmpty)
 {
     for(lead ld: lstleads)
     {
     
     lstwrapper.add(new customerwrapperclass(ld,false));
     
     }
 
 }

}

}
Let me know if you have any issues.

Mark it as best answer if it works.

Thanks.
 
This was selected as the best answer
Dilip_VDilip_V
In your org you might have two classes with the same name.

Please check it once and let me know.
Source:http://www.solutions.forcetree.com/2015/11/error-commonexceptionsqldupvalonindexex.html

Or It may be bug:
https://success.salesforce.com/ideaView?id=08730000000DpYoAAK

Thanks.