+ Start a Discussion
alchemyalchemy 

code

i have com e accross the following code

AssetRecTypes__c.getInstance('Retirement Accounts').Name

 Here AssetRecTypes is a custom setting and Retirement Accounts is my Record Type Name.

but then this line is giving me an error 

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

can i get a solution for it....

Prafull G.Prafull G.

make sure you have inserted record in custom setting for "Retirement Accounts".

I believe the NULL pointer exception is because there is no record in custom setting for "Retirement Accounts".

alchemyalchemy

but i dnt want NY VAUES IN BEGINING. IS DER ANY OTHER WAY OF PUTTING THE ABOVE CODE

Prafull G.Prafull G.

You should incorporate error handling in the code.

i.e. you have to handle the Exception correctly.

 

try something like

String nm;

if(AssetRecTypes__c.getInstance('Retirement Accounts') != null)

   nm = AssetRecTypes__c.getInstance('Retirement Accounts').Name;

 

Try this.