4

Documentation Custom Settings Methods says:

getOrgDefaults():

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

9

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.

0
0

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

if(customsetMap.isEmpty())

returns true or false

another way is

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

to check the size

1
  • I'm trying to check the Org Defaults, not all settings..
    – itsmebasti
    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 .