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
Carly Probasco 14Carly Probasco 14 

|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object

|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object

I'm getting the above error in this piece of code
//Returns the Rating Release date or the 'rating pending'
        IF (Today < currentQRpCase.Rating_Externally_Visible_Date__c){
            RatingRelease = 'Rating Pending';
        } else IF(Today > currentQRpCase.Rating_Externally_Visible_Date__c){
            RatingRelease = currentQRpCase.Rating_Externally_Visible_Date__c.format();
        } else {
            RatingRelease = '';
        }

On my test record, Rating_Externally_Visible_Date__c is not null.
 
Help troubleshooting!
Carly Probasco 14Carly Probasco 14
public String RatingRelease {get;set;}
Today = System.today();

 
Suraj MakandarSuraj Makandar
Hi Carly Probasco 1,

Please use debug statements and make sure you are getting record in "currentQRpCase" variable and field value in  "Rating_Externally_Visible_Date__c".

These are the only points where you are can get Null pointer error.

Thanks,
Suraj
Mahesh NirmalMahesh Nirmal

Hi Carly,
You can put the Null Check before the "Rating_Externally_Visible_Date__c" even it is not Null.

This might help you to troubleshoot.