You need to sign in to do that
Don't have an account?

Compile Error: Initial term of field expression must be a concrete SObject: LIST<Branch__c>
Hi,
I am getting an error : Error: accCont Compile Error: Initial term of field expression must be a concrete SObject: LIST<Branch__c> at line 52 column 21
My Controller is as follows
public with sharing class accCont { Public Account acc{get;set;} ApexPages.StandardController con; public List<Branch__c> branch; public accCont(ApexPages.StandardController controller) { con = controller; this.acc = (Account) controller.getRecord(); branch= new List<Branch__c>(); } public pagereference redirect(){ con.save(); Account a = (Account) con.getRecord(); a.recordtypeid='012f00000004Jfk'; a.LastName = a.Last_Name__pc; a.FirstName = a.First_Name__pc; insert a; pagereference ref= new pagereference('/apex/personaccpage'); ref.setredirect(true); return ref; } public pagereference save(){ Account a = (Account) con.getRecord(); a.recordtypeid='012f00000004Jfk'; a.LastName = a.Last_Name__pc; a.FirstName = a.First_Name__pc; insert a; String id = ApexPages.CurrentPage().getparameters().get('id'); //return new pagereference('/apex/customerdetail?id='+a.id); PageReference acctPage = new PageReference('/apex/customerdetail'+'?id='+a.id); acctPage.setRedirect(true); return acctPage; } Public pagereference AccView() { acc=new Account(); insert acc; PageReference accview =new pagereference('/'+acc.id); accview.setRedirect(true); return accview; } public void fetchRecords() { //system.debug('****b.Branch_ID__pc****'+b.BranchName__pc); branch= [Select BranchId__c from Branch__c where id=: acc.Branch__pc]; if(acc.size()>0){ branch.BranchId__c = acc[0].BranchId__pc; } } }
Pleae help me with this. Any help will be appreciated
branch is declared as a list, but you are treating it as a single object in this line:
you should probably check that the list contains a value and then set the id on the zero'th element of the list:
Replace the first line I posted above with the lower two.
try this
replace ur code
// branch.BranchId__c = acc[0].BranchId__pc;
branch.BranchId__c = acc.BranchId__pc;