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
imAkashGargimAkashGarg 

Custom setting not accessible from test class

i have a List custom setting defined.

 

There is a button on the accounts page, which redirects to an URL.

the URL is generated from a class which returns the URL.

This class uses the custom setting values.

 

the button is working fine, also i am getting the right result even on changing the custom setting value.

 

The problem comes in the test class:

it says:

"Null Pointer Exception: Argument 1 cannot be null"

 

The custom setting has default values, i.e. is accessible to anyone.

 

The code is like:

    EncryptionVariables__c CS = EncryptionVariables__c.getInstance('Org');
           return Blob.valueOf(CS.MyAESKey__c);

 

 

Need Help

Best Answer chosen by Admin (Salesforce Developers) 
Rahul_sgRahul_sg

issue solved!! :)

 

just changes ur version to 23.0 ( I faced the same issue today  :P)

 

 

this is due to 24.0 version

 

 

Thanks

Rahul

404-314-2068

All Answers

Rahul_sgRahul_sg

chk Custom setting values in MyAESKey__c is it of string datatype?

use syste.debug()

Rahul_sgRahul_sg

issue solved!! :)

 

just changes ur version to 23.0 ( I faced the same issue today  :P)

 

 

this is due to 24.0 version

 

 

Thanks

Rahul

404-314-2068

This was selected as the best answer
imAkashGargimAkashGarg

hey super.... thanks a lot!

 

its working :)

 

does the change of version affect my code?

does that mean the code is not supported in v24?

partha_cegpartha_ceg

Looks like this is an issue with accessing custom settings values in test class for API 24. check this link for detail

RajanJasujaRajanJasuja

Use

 

@isTest(SeeAllData=true)
with API v24 and it will fix the issue.