Documentation Custom Settings Methods says:


If no custom setting data is defined for the organization, this method returns an empty custom setting object.

How to check if it is empty, because == null is not working here.

    XyCustomSettings__c customSettingObject = XyCustomSettings__c.getOrgDefaults():
    Boolean checkboxSet = (customSettingObject == null)?true:customSettingObject.checkbox_Activated__c;

I also tried

if (customSettingObject.checkbox_Activated__c == null)

didn't work.

2 Answers 2


For hierarchy settings, you can use:

Settings__c.getOrgDefaults().Id == null

If there was no data, there would be a null ID value; otherwise you would have a non-null ID value.


To get all the custom setting values if custom setting name is customse__c

Map<String,customse__c> customsetMap = customse__c.getAll();

check the map empety or not by using isEmepty method


returns true or false

another way is

list<customse__c> customList = customse__c.getAll().Values();

to check the size

  • I'm trying to check the Org Defaults, not all settings..
    – itsmebasti
    Commented Aug 7, 2013 at 16:10

You must log in to answer this question.

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