function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Atosi MalakarAtosi Malakar 

Can you help me with Apex code to check if a custom setting is list or hierarchy? Is there any way to check that?

SwethaSwetha (Salesforce Developers) 
HI Atosi,

Try
String customSettingName = 'Your_Custom_Setting__c';
Schema.DescribeSObjectResult describeResult = Your_Custom_Setting__c.SObjectType.getDescribe();

if (describeResult.isCustomSetting()) {
    if (describeResult.getObjectType() == Schema.DisplayType.LIST) {
        // Custom setting is of list type
        System.debug('Custom setting is of list type');
    } else if (describeResult.getObjectType() == Schema.DisplayType.HIERARCHICAL) {
        // Custom setting is of hierarchy type
        System.debug('Custom setting is of hierarchy type');
    } else {
        // Custom setting is of another type
        System.debug('Custom setting is of another type');
    }
} else {
    // Object is not a custom setting
    System.debug('Object is not a custom setting');
}

Related:
 https://salesforce.stackexchange.com/questions/191044/using-the-describe-api-how-can-i-tell-whether-a-given-custom-setting-is-of-list

https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_custom_settings.htm

https://www.apexhours.com/salesforce-custom-settings/

If this information helps, please mark the answer as best. Thank you