You need to sign in to do that
Don't have an account?
Nagaraju 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;
}
}
}
//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;
}
}
}
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.