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 

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

I am getting the above error from this piece of code.
public Set<String> RatingRelease {get;set;}

//Returns the Rating Release date or the rating pending
        IF (Today < currentQRpCase.Rating_Externally_Visible_Date__c){
           String RatingRelease = 'Rating Pending';
        } else IF(Today > currentQRpCase.Rating_Externally_Visible_Date__c){
           String RatingRelease = currentQRpCase.Rating_Externally_Visible_Date__c.format();
        } else {
           String RatingRelease = '';
        }

 
Maharajan CMaharajan C
Hi Carly,

Please do the null check like below:

public Set<String> RatingRelease {get;set;}

//Returns the Rating Release date or the rating pending

    if(currentQRpCase.Rating_Externally_Visible_Date__c != null)
    {
        IF (Today < currentQRpCase.Rating_Externally_Visible_Date__c){
           String RatingRelease = 'Rating Pending';
        } else IF(Today > currentQRpCase.Rating_Externally_Visible_Date__c){
           String RatingRelease = currentQRpCase.Rating_Externally_Visible_Date__c.format();
        } else {
           String RatingRelease = '';
        }
    }
    else {
        String RatingRelease = '';
    }

Thanks,
Maharajan.C