Accessing Hierarchy Custom Setting data

You can similarly try accessing the Hierarchy Custom Setting data with the following methods.

  • To return a custom setting data set record for the current logged in user. Use the getInstance() method.
  • To return a custom setting data set record for a specific userId/ProfileId, Use the getInstance(userId/ProfileId) method.
  • To return the custom setting record data set for the organization, Use the getOrgDefaults() method
 

Note: To make the Custom Setting data visible in your apex test class, use “seeAllData=true”.

    
        CustomSettingApiName var = CustomSettingApiName.getInstance();
    
    
    CustomSettingApiName var = CustomSettingApiName.getInstance(userId/ProfileId);
    
    
        CustomSettingApiName var = CustomSettingApiName.getOrgDefaults();