+ Start a Discussion
Tena WolverTena Wolver 

deploy to production trigger can't access custom settings

In my trigger and global classes when I try to retreive values from my public custom setting I get a System.NullPointerException.  This occurs when I try to deploy to production because it needs those values in order to do some logic.

How do I get around this?
Himanshu ParasharHimanshu Parashar
Hi Tena,

Are you facing this issue in Test Class while deploying ?


Thanks,
Himanshu
Tena WolverTena Wolver
Yes only an issue when I deploy to production and I do have SeeAllData=true.  However if I hard code the values it works fine but once I use the custom settings it doesn't deploy.  It does work when I run the test Classes in the Sandbox and in use of the functionality. 
Shailesh DeshpandeShailesh Deshpande
You would need to create a custom setting record in the Test class, just as we create records for object in test class. That should solve the problem.
Himanshu ParasharHimanshu Parashar
hmmm.. Strange it should work with SeeAllData=true, Try to degrade the test class version to API version 23.0. second, can you post your code? so that we can catch any error if it exist there. I am not questioning you coding skills but sometimes it happens that as developer we miss small problem.

 
Tena WolverTena Wolver
SeeAllData did work it was just an issue with a test class that I wasn't aware of using the functionality that I changed.  I was able to create the setting just like Shailesh said and it worked perfectly.  I guess I wasn't aware you had to do that when not using SeeAllData.  

Thanks !!