21

What is the difference between Custom Setting Type "List" and "Hierachy"?

1 Answer 1

31

What's your use case? One will fit better than the other.

Hierarchy custom settings can be configured at varying user specificity levels under a single name; the platform will look for the most specific configuration first, then fall back / inherit to the least specific:

  • setting per user,
  • setting per profile,
  • setting for whole org,

Hierarchy custom settings are easily retrieved in Visualforce: {!$Setup.Setting__c.Field__c} and will be resolved according to the current user context.

hierarchy custom setting

List custom settings have user-independent values, retrieved under multiple names. For example, you could use several configs to hold the credentials for a web service callout so that you can swap the endpoints:

  • setting for development environment,
  • setting for volume testing environment,
  • setting for production environment,

List custom settings need to be accessed using a controller if you want to avail them on a page, for example return ListSetting__c.getInstance('dev').Field__c;

list custom setting

8
  • I might adjust the wording of the last statement, as you typically wouldn't want to "query" a custom setting in Apex, you use an accessor method to retrieve the cached setting values. But good answer otherwise.
    – pchittum
    Feb 25, 2013 at 9:51
  • 1
    At the moment I don't have complicated use cases, I have been working with List most of the time, I didn't have a clue what Hierarchy was, and wanted a clear explanation that showed the differences between List and Hierachy, thanks, i'll be checking that out!
    – pjcarly
    Feb 25, 2013 at 10:22
  • 1
    Great answer. I would suggest amending from "Sometimes one or the other is a more appropriate fit..." to "One or the other is always a more appropriate fit..." since they are so different in their usage. Lists are great for global registry-like settings, and hierarchy are great for settings that may need different values for different groups or individual users. I've never seen a requirement that could "correctly" be satisfied by either - one is always more appropriate than other, but both are very useful.
    – jkraybill
    Feb 25, 2013 at 11:36
  • 1
    thanks WesNolte and @jkraybill - I've differentiated 'org-wide under multiple names' vs 'user-specific under a singular name' Feb 25, 2013 at 12:03
  • 2
    Very nice answer buddy! Screenshots with drop-shadows - what the... ;-) I would perhaps suggest providing a different example use case for list settings - I think the docs use tax codes - to distinguish the types even more clearly Feb 26, 2013 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.