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
ReddyReddy 

Compile Error: Initial term of field expression must be a concrete SObject: List<Account> at line 18 column 41

public class AccountInsert{
    public string accName{get;set;}
    public string accindustry{get;set;}
    public pagereference create(){
    
    list<Account> acc =[select id, name, industry from Account where name=:accname ];
    if(acc.size()>0){
    apexpages.message msg=new Apexpages.Message(apexpages.Severity.Error, 'duplicate records Exit');
    apexpages.addMessage(msg);
    return null;
    }
    else{
    account a=new Account();
    a.name='accname';
    a.industry='accIndustry';    
    insert a;
    }
 pagereference p=new pagereference('/'+ acc.id);
 return p;
   }
}
Best Answer chosen by Reddy
sfdcMonkey.comsfdcMonkey.com
hi Reddy
try this onces
pagereference p = new pagereference('/'+ acc[0].id);
let me inform if it helps you
thanks

 

All Answers

sfdcMonkey.comsfdcMonkey.com
hi Reddy
try this onces
pagereference p = new pagereference('/'+ acc[0].id);
let me inform if it helps you
thanks

 
This was selected as the best answer
ReddyReddy
Ya Thanking @piyush.
Its working but what is debug code.

AccountInsert ai=new AccountInsert();
ai.create();
 or
AccountInsert ai=new AccountInsert();
ai.pagereference();
 pls let tel me

allways debug code will be written by
 ClassName ver=new Classname();
  ver.Constructor();------------- syntax.
 jest tell me