You need to sign in to do that
Don't have an account?
Automate Process
System.NullPointerException: Attempt to de-reference a null object - Apex Class Error
Hi Team,
I am new to visualforce coding. I was tyrying to do some customization on the case object but whenever I am trying to save the record into the object its throwing me: System.NullPointerException: Attempt to de-reference a null object" error. Any help in this regard is much appreciated.
Below goes by VF page code:
and the detailsController is as below:
I am new to visualforce coding. I was tyrying to do some customization on the case object but whenever I am trying to save the record into the object its throwing me: System.NullPointerException: Attempt to de-reference a null object" error. Any help in this regard is much appreciated.
Below goes by VF page code:
<apex:page StandardController="Case" extensions="detailsController" showHeader="False" sidebar="False"> <apex:form > <apex:pagemessages ></apex:pagemessages> <apex:pageBlock id="pb" > <apex:pageBlockSection title="Please fill in the below details"> <apex:inputField value="{!c.user_fname__c}"/> <apex:inputField value="{!c.user_lname__c}"/> <apex:inputField value="{!c.user_alias__c}"/> <apex:inputField value="{!c.user_email__c}"/> <apex:inputField value="{!c.user_CommunityNickname__c}"/> <apex:inputField value="{!c.user_role__c}" required="True"/> <apex:inputField value="{!c.user_license__c}" required="True"/> <apex:inputField value="{!c.user_profile__c}" required="True"/> <apex:inputField value="{!c.user_EmailEncodingKey__c}" required="True"/> </apex:pageblocksection> </apex:pageBlock> <center> <apex:commandButton value="Save" action="{!saveRec}"/> <apex:commandButton value="Reset All" action="{!resetAll}" immediate="True"/> <apex:commandButton value="Cancel & Back to Previous" action="{!returnBack}" immediate="true"/> </center> </apex:form> </apex:page>
and the detailsController is as below:
<apex:page StandardController="Case" extensions="detailsController" showHeader="False" sidebar="False"> <apex:form > <apex:pagemessages ></apex:pagemessages> <apex:pageBlock id="pb" > <apex:pageBlockSection title="Please fill in the below details"> <apex:inputField value="{!c.user_fname__c}"/> <apex:inputField value="{!c.user_lname__c}"/> <apex:inputField value="{!c.user_alias__c}"/> <apex:inputField value="{!c.user_email__c}"/> <apex:inputField value="{!c.user_CommunityNickname__c}"/> <apex:inputField value="{!c.user_role__c}" required="True"/> <apex:inputField value="{!c.user_license__c}" required="True"/> <apex:inputField value="{!c.user_profile__c}" required="True"/> <apex:inputField value="{!c.user_EmailEncodingKey__c}" required="True"/> </apex:pageblocksection> </apex:pageBlock> <center> <apex:commandButton value="Save" action="{!saveRec}"/> <apex:commandButton value="Reset All" action="{!resetAll}" immediate="True"/> <apex:commandButton value="Cancel & Back to Previous" action="{!returnBack}" immediate="true"/> </center> </apex:form> </apex:page>
public Case c {get; set;}
You have to initialize it in the Constructor.
public detailsController(ApexPages.StandardController stdController) {
c = (Case) stdController.getRecord();
}
Also paste the controller code here if it doesn't work.
Please do let me know if it helps you.
Regards,
Mahesh
All Answers
public Case c {get; set;}
You have to initialize it in the Constructor.
public detailsController(ApexPages.StandardController stdController) {
c = (Case) stdController.getRecord();
}
Also paste the controller code here if it doesn't work.
Please do let me know if it helps you.
Regards,
Mahesh
That worked perfectly..!! Thank you so much for your quick help