1

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

2 Answers 2

1

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 ? '' : 
    rws__T2_RWS_SiteProductMap__c.getInstance(site.getName()).rws__SFDC_InsuranceProductName__c
0

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.

1
  • I had salesforce enable debug logs for all namespaces in the subscriber org, so I doubt this is the reason. Jul 3, 2013 at 18:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .