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
Nagireddy ManoharNagireddy Manohar 

Why Hierarchy custom settings are required. if we can achieve same through list custom settings.

Why Hierarchy custom settings are required. if we can achieve same through list custom settings.
Example:
while creating data in Hierarchy custom settings, we need to select user or profile, we can acess those values in apex by using below piece of code.
CustomSettingName__c mc = CustomSettingName__c.getInstance(Profile_ID);
CustomSettingName__c mc = CustomSettingName__c.getInstance(User_ID);

If we use list custom setting, while creating data if we give name as userid or profileid, we can access those values in apex by using below piece of code.
CustomSettingName__c mc = CustomSettingName__c.getValues(userinfo.getuserid());
CustomSettingName__c mc = CustomSettingName__c.getValues(userinfo.getprofileid());

So we can achieve  using list custom settings also .Then what is the main use of Hierarchy custom settings comapred to list custom settings?  
Please let me know is there any specific reason to create Hierarchy custom settings?.

Thanks & Regards,
N. Manohar


 
NagendraNagendra (Salesforce Developers) 
HI Manohar,

May I suggest you please check with below Jeff Douglas blog which has a clear explanation on using hierarchy custom settings and list custom settings with scenarios. Please let us know if the information helps.

Regards,
Nagendra.