Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Hierarchy Custom Settings entry
How-to guide

Create and use a Hierarchy Custom Setting

Setting up a Hierarchy Custom Setting involves creating the setting metadata, adding fields, populating values at each hierarchy level, and accessing the values in Apex. The steps below cover the full setup.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated May 19, 2026

Setting up a Hierarchy Custom Setting involves creating the setting metadata, adding fields, populating values at each hierarchy level, and accessing the values in Apex. The steps below cover the full setup.

  1. Create the Custom Setting

    Setup > Custom Settings > New. Name it descriptively (FeatureFlag__c), set Setting Type to Hierarchy, choose Public or Protected visibility. Save.

  2. Add fields

    From the Custom Setting detail, add fields (Checkbox for feature flags, Text for endpoint URLs). Field types are limited; complex types require a custom object instead.

  3. Set the org-wide default

    From the Custom Setting > Manage, click New (in the organization section). Enter values for each field. Save. This is what every user sees absent any override.

  4. Add profile-level overrides

    Still in Manage, click New (in the profile section). Pick the profile, enter values. Save. Users with that profile now see the override instead of the org default.

  5. Add per-user overrides if needed

    Add specific user overrides only for genuine per-user needs. Most settings do not need this level.

  6. Access from Apex

    In Apex, call MySetting__c.getInstance() to get the running-user value with full hierarchy lookup. Use getOrgDefaults() to bypass hierarchy and read just the org default.

  7. Plan deployment

    The setting schema deploys through changesets. The data (org defaults, profile overrides) does not. Write a post-deployment Apex script or use Data Loader to populate values in each environment.

Key options
Organization-level defaultremember

The base value every user sees absent any override. Set first.

Profile-level overrideremember

Override for a specific profile. Takes precedence over org default.

User-level overrideremember

Override for a specific user. Highest precedence; takes precedence over profile and org.

Public visibilityremember

Accessible from any Apex code. The standard choice for application settings.

Protected visibilityremember

Accessible only from Apex within the same namespace. For managed packages.

Gotchas
  • Custom Setting data does not deploy through changesets. The schema does; values must be populated in each environment separately. Plan deployment scripts.
  • Custom Setting data is capped at 10 MB total across all settings. Large or many settings hit the cap; plan storage carefully.
  • Updates take a few seconds to propagate across all servers. Code that updates and immediately reads may return stale values briefly.
  • Per-user overrides should be rare. Reserve for personal preferences; for most settings, profile overrides are sufficient and easier to maintain.
  • Custom Settings cannot have validation rules, triggers, or sharing rules. For configuration needing those, use a custom object instead.

See the full Hierarchy Custom Settings entry

Hierarchy Custom Settings includes the definition, worked example, deep dive, related terms, and a quiz.