+ Start a Discussion

DEBUG|Attempt to de-reference a null object

Hi all,

I am getting this error when i put system.debug

Error:- Attempt to de-reference a null object
In this line i am getting error
system.debug('ProertyVisit Length - '+ p.Visit_Restrictions__c.length());

Arunkumar RArunkumar R
Hi Kumar,

Referring field( p.Visit_Restrictions__c) seems to be null, so you are getting deference error. You can check null condition before getting length..

if(p.Visit_Restrictions__c != null)
system.debug('ProertyVisit Length - '+  p.Visit_Restrictions__c .length() );
Ajay K DubediAjay K Dubedi
Hey Kumar,
         In the above comments by ArunKumar that nothing is coming up with p.Visit_Restrictions__c so you should debug the issue for that 
         and use that null condition so that your code will not fail.
Prosenjit Sarkar 7Prosenjit Sarkar 7
Hi Kumar,
Try this,
if(p.Visit_Restrictions__c != NULL)
 system.debug('ProertyVisit Length - '+ p.Visit_Restrictions__c.length());