You need to sign in to do that
Don't have an account?

Custom Setting getOrgDefaults not returning Null anymore
According to the documentation when you call getOrgDefaults on a Custom Setting it should return null if there are no Org Defaults defined. Since the Spring 12 release this method is not returning null but instead is returning a blank object. Try the following code from the Developer Console on a custom setting with no values defined. This causes problems if you have code that has defaults defined in the case of the Custom Setting not being configured yet (i.e. getOrgDefaults returning NULL).
System.debug(YourCustomSetting__c.getOrgDefaults());
The debug output will look like below instead of saying Null
10:05:08:098 USER_DEBUG [1]|DEBUG|YourCustomSetting__c:{}
Has anyone else noticed this? I am going to log a case with Developer Support as well.
The semantics changed in v.24. If you're seeing this in v.23 or earlier then, yes, please, file a case.
To get null back if there's no org-level data in v.24, I'd suggest using getValues(UserInfo.getOrganizationId())
A fuller description of custom settings semantics in v.24 is here:
http://thecodestuff.wordpress.com/2012/02/14/hierarchy-custom-settings-semantics-explained/
All Answers
The Spring '12 documentation says it should be null. It's definitely a bug.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_custom_settings.htm?SearchType=Stem&Highlight=getOrgDefaults
The semantics changed in v.24. If you're seeing this in v.23 or earlier then, yes, please, file a case.
To get null back if there's no org-level data in v.24, I'd suggest using getValues(UserInfo.getOrganizationId())
A fuller description of custom settings semantics in v.24 is here:
http://thecodestuff.wordpress.com/2012/02/14/hierarchy-custom-settings-semantics-explained/
Thanks for the link, Rich. The documentation should probably be updated, it seems fairly confusing.
FYI, It is happening in a class marked with apiVersion 23 in the meta file. I have changed the code to use your suggestion of getValue and passing in the Org Id, seems to be working according to the documentation. I have logged a case with Developer support as well.
The return value of getOrgDefaults() changed starting with version 22.0 actually (and not 24). Sorry for the misleading information in the documentation. In version 21.0 null is returned but in versions 22.0 and up, an empty custom setting object is returned if no data is defined.
We'll be updating the doc with the correct info. Thanks for catching this.