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
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.