I have two identical statements that I am running in execute anon and I am getting different results based on the which org I am running it against.

In my packaging org if I run the code below, I get the value in the custom setting.

String customSettingVal =rws__T2_RWS_SiteProductMap__c.getInstance(site.getName()).rws__SFDC_InsuranceProductName__c
System.debug('----> '+customSettingVal);

If I run the same code as above (again from execute anon) in a subscriber org I get a null value returned.

Question is why the different behavior ? and why does it even work in the packaging org, surely site.getName() would return null anyway when run from execute anon. I have tried printing the contents of site.getName() and it is null in both orgs when in execute anon

Gotta love salesforce sometimes


I believe there is a bug where passing in NULL into getInstance returns a value despite there not being a key for NULL in the custom settings. I would NULL check site.getName() before passing it into getInstance.

For example:

String customSettingVal = site.getName() == NULL ? '' : 

All managed package debug code is hidden from the subscriber. If you need to see it, log in via the LMA, then create a debug log for the user you're logged in as.

  • I had salesforce enable debug logs for all namespaces in the subscriber org, so I doubt this is the reason. – Mahat Hussein Jul 3 '13 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.