Custom Settings and Custom Metadata Patterns

Pattern Intent: Centralize configuration so that logic and data can change at different speeds without code rewrites or risky production edits.

Overview

Custom Settings and Custom Metadata Types provide declarative configuration storage:

This document explains how to choose between them and how to structure configuration for Flows, Apex, and integrations.

Prerequisites

When to Use

Use Custom Metadata When

Use Custom Settings When

Avoid Both When

Core Concepts

Configuration as Data

Treat configuration as data:

Lookup by External Keys

Use stable keys (e.g., DeveloperName, external Id-style fields) to look up CMDT or settings:

Patterns and Examples

Pattern 1: Feature Flag via Hierarchy Custom Setting

Pattern 2: CMDT-Driven Routing Rules

Pattern 3: Decision Framework: Custom Object vs CMDT vs Custom Setting

Use the decision frameworks described in the Decision Frameworks section of the repo (to be expanded) to select the right storage based on:

Edge Cases and Limitations

Q&A

Q: When should I migrate from Custom Settings to Custom Metadata?

A: Migrate when you need deployment control, versioning, or packaging for configuration. CMDT is preferred for long-lived configuration, while Custom Settings are better for environment-specific toggles and hierarchy overrides.

Q: Can I use CMDT in Flows?

A: Yes. Modern Flows can reference CMDT via Get Records and decision elements. This enables configuration-driven Flows where business rules are stored outside the Flow definition.