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
RyanhRyanh 

Attempt to de-reference a null object

I don't understand why I'm getting this error... I have the following code:

 

System.debug('BillingStreet = \'' + account.BillingStreet + '\'\n');

System.debug('BillingState = \'' + account.BillingState + '\'\n');

 

if (account.BillingStreet == '' || account.BillingStreet == null) ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.ERROR, 'The account must have a billing address.') );

 

If I remove the OR condition in the if statement, debug outputs the following:

BillingStreet = 'null'

BillingState = 'CA'

 

If I leave that in, I get the error: "Attempt to de-reference a null object"; the error refers to the "account.BillingStreet" test for null...

 

If I only test for null -- instead of empty string -- then I get the following error: 

 

Data Not Available
The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. [...]

 

'account' is not null BillingState is getting outputted (sp?) just fine.

 

 

WTF?

 

Message Edited by Ryanh on 03-19-2009 02:04 PM