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
kumar.fdc81.3902978579608325E12kumar.fdc81.3902978579608325E12 

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());

Thanks
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());