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

Object reference not set to an instance of an object.

I get the following error when I attempt to get the users phone number.  My assumption is that we are failing to log the user in..  My concern is that this error only happens occasionally. When it does the problem will last for 10 minutes or so then it will work correctly without any code modifications.  any thoughts?

Object reference not set to an instance of an object.


Line 439: AuthenticateUser();
Line 440: //Get the phone number of the user
Line 441:                   UserPhoneNumber = FormatPhone(GetSFUserPhone());


Hi May,

Well, seems like something you are assuming exists doesn't, but I have to say it's very hard to go any deeper than that given the code snippet you posted.

I have no idea what is happening in AuthenticateUser(), FormatPhone() or GetSFUserPhone() and I suspect that the error has bubble up from one of those calls.

Are you checking to see if the Phone value is null, or that the query as returned any records?

Are you using the enterprise wsdl or the partner wsdl?

I would be more than happy to assist you, but you will need to give me a fighting chance.