Activity Forums Salesforce® Discussions What is the difference between list custom setting and hierarchy custom setting?

  • prabhat

    Member
    June 24, 2016 at 11:04 am

    Custom setting like as Custom object where you can store your data .

    major difference  is :

    1  - Do not need to Query to access Data We can directly access them using methods 

    2 -
    List custom setting :  Every User can Access
    hierarchy custom setting : restrict data by user by Using ( User Id) .

    3 - No owner is assigned when a custom setting is created

    • This reply was modified 8 years, 4 months ago by  prabhat.
  • Surbhi

    Member
    June 24, 2016 at 2:30 pm

    Hi Prabhat,

    Thanks for providing this information. Can you please provide some examples of using hierarchy custom settings in apex ?

    Thanks in advance

  • Incredible Inside

    Member
    July 15, 2018 at 7:03 am

    Hi Surbhi,

    There are separate methods for Hierarchy custom settings and list custom settings.

    For example, I have used one method getorgdefaults() in code. So basically what happens in this case is, the code fetches the field details from that custom setting and gets used. In my case, it was a batch class.

    So you can follow this URL to get somewhat idea regarding this:

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

    And when you go to custom settings you can see what type is it(hierarchy/list)...

    Regards,
    Siddhartha

  • Parul

    Member
    September 18, 2018 at 8:16 am

    HI

    Custom settings are similar to custom objects and enable application developers to create custom sets of data, as well as create and associate custom data for an organization, profile, or specific user. All custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database. This data can then be used by formula fields, validation rules, Apex, and the SOAP API.

    There are two Types of Custom settings
    List Custom Settings : A type of custom setting that provides a reusable set of static data that can be accessed across your organization. If you use a particular set of data frequently within your application, putting that data in a list custom setting streamlines access to it.

    Hierarchy Custom Settings : Hierarchy settings allow you to personalize your application for different profiles and/or users. A type of custom setting that uses a built-in hierarchical logic that lets you “personalize” settings for specific profiles or users. The hierarchy logic checks the organization, profile, and user settings for the current user and returns the most specific, or “lowest,” value. In the hierarchy, settings for an organization are overridden by profile settings, which, in turn, are overridden by user settings.

     

    Thanks

  • shariq

    Member
    September 21, 2018 at 12:09 am

    Hi,

    Hierarchical Custom Settings

    Use this for your most of your VF/Apex config settings for stand alone apps
    Don’t put in settings which are environment dependent (e.g. if you have separate test server URLs that should be used in Sandbox vs. Production)
    Definitely, if you are storing User Preferences, Hierarchical is the way to go.
    List Custom Settings

    Use this if you creating config for a common piece of code that appears in different areas of Salesforce
    Use this when there are environmental differences such as Test server URLs vs. Production server URLs
    Also can be used as a simple table for frequently used data

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs