Hi Nishant,'accName' variable is not initialized so in method 'getAccountDetails()' there will be no result for 'accList' i.e. accList will be null. Due to this 'accObj' will also be null and it will throw exception where you are checking 'accObj.Account_Type__c!='Client''. So in Search_Account_Controller constructor initialize 'accName' & 'accObj' :
public Search_Account_Controller() {
recTypeCheck=true;
accountSet = new Set<String>();
accName = '';
accObj = new Account();
List<Account> accList = [Select id, Name, Account_Type__c from Account LIMIT
30000];
if(accList!=null && accList.size()>0){
for(Account acc :accList){
accountSet.add(acc.Name);
}
}
}
Also update 'getAccountDetails()' method :
public void getAccountDetails(){
oppList = new List<Opportunity>();
serviceList= new List<Service__c>();
List<Account> accList= [Select Name, Id, Account_Type__c from Account where
Name=:accName LIMIT 1];
if(accList!=null && accList.size()>0){
accObj=accList[0];
if(accObj.Account_Type__c!='Client') {
recTypeCheck=false;
}
else{
oppList=[Select Id, OppNumber__c, FC_Opportunity_Status__c, Name,
StageName, CloseDate, CreationDateTime__c from Opportunity where
AccountId=:accObj.Id];
}
}
}
3 answers