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
Nagaraju Mogili 25Nagaraju Mogili 25 

I am getting the this Error for the below class, can any one help me to solve this: AccountSelectClassController Compile Error: Loop variable must be a generic SObject or List or a concrete SObject or List of: Account at line 10 column 13

public class AccountSelectClassController{
 
    //Our collection of the class/wrapper objects wrapAccount
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Account> selectedAccounts{get;set;}
 
    public AccountSelectClassController(){
        if(wrapAccountList == null) {
            wrapAccountList = new List<wrapAccount>();
            for(Account a: [select Id, Name,BillingState, Website, Phone from Account limit 10]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapAccountList.add(new wrapAccount(a));
            }
        }
    }
 
    public void processSelected() {
    selectedAccounts = new List<Account>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList) {
            if(wrapAccountObj.selected == true) {
                selectedAccounts.add(wrapAccountObj.acc);
            }
        }
    }
 
    // This is our wrapper/container class. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapAccount {
        public Account acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Account a) {
            acc = a;
            selected = false;
        }
    }
}
Venkata Naresh Thatha 8Venkata Naresh Thatha 8
Hi, i just tried to compile it in my DE i did not see any errors. Do you want to cross check if the error is related to any other class by chance ?
Amit Chaudhary 8Amit Chaudhary 8
Hi ,

I am able to save your above code in my developer org. Please you have any apex class with Account Name ? If yes then please try to rename the class and try again.