You need to sign in to do that
Don't have an account?
Dagny Fernandes
for wrapper class Null pointer Exception: Attepting to de-reference a null object
Iam getting the null pointer exception while useing the wrapper class my other wrapper class code are working fine not able to understand what went wrrong in this code. need Help ASAP
public list<WrapperClass> wrapper_variable {get;set;}
Account_Project_Junction__c projRec = [SELECT Id,Name,Project__c,Project__r.Name from Account_Project_Junction__c WHERE Id = 'a00O000000KWbzsIAD'];
Escalation_Project_Junction__c EscaProjJunRec = new Escalation_Project_Junction__c();
EscaProjJunRec.Project__c = projRec.Id;
EscaProjJunRec.Project_Name__c = projRec.Project__r.Name;
wrapper_variable.add(new WrapperClass(EscaProjJunRec));
//wrapper class
public class WrapperClass{
public Escalation_Project_Junction__c projectEsca_wrapper{get;set;}
public WrapperClass(Escalation_Project_Junction__c EPJ){
projectEsca_wrapper = EPJ;
}
}
Error:
05:29:16:077 FATAL_ERROR System.NullPointerException: Attempt to de-reference a null object
this error is for the line
wrapper_variable.add(new WrapperClass(EscaProjJunRec));
public list<WrapperClass> wrapper_variable {get;set;}
Account_Project_Junction__c projRec = [SELECT Id,Name,Project__c,Project__r.Name from Account_Project_Junction__c WHERE Id = 'a00O000000KWbzsIAD'];
Escalation_Project_Junction__c EscaProjJunRec = new Escalation_Project_Junction__c();
EscaProjJunRec.Project__c = projRec.Id;
EscaProjJunRec.Project_Name__c = projRec.Project__r.Name;
wrapper_variable.add(new WrapperClass(EscaProjJunRec));
//wrapper class
public class WrapperClass{
public Escalation_Project_Junction__c projectEsca_wrapper{get;set;}
public WrapperClass(Escalation_Project_Junction__c EPJ){
projectEsca_wrapper = EPJ;
}
}
Error:
05:29:16:077 FATAL_ERROR System.NullPointerException: Attempt to de-reference a null object
this error is for the line
wrapper_variable.add(new WrapperClass(EscaProjJunRec));
All Answers