Read the screenplay: FANNIEGATE — $7 trillion. 17 years. The biggest fraud in American capital markets.
ApexIntermediate2026-03-04

Custom Metadata Types: Runtime Configuration Without Deployments

Custom Settings were the old way to store configuration. Custom Metadata Types are the upgrade, and the difference matters. Custom Metadata records are metadata, not data. They deploy with change sets, they are available in formula fields, they work in flows, and they are accessible in Apex without counting against SOQL limits when you use the getInstance methods.

The killer use case is feature flags and runtime configuration. Instead of hardcoding thresholds, API endpoints, or business rules in Apex, store them in Custom Metadata. Need to change the approval threshold from 10,000 to 25,000? An admin updates the metadata record in production. No deployment. No code change. No developer needed. I use this pattern for everything: email templates, integration endpoints, flow behavior toggles, and retry counts.

Design your Custom Metadata with a DeveloperName that acts as a key. Use the Metadata API or deploy via change sets to move records between environments. Unlike Custom Settings, Custom Metadata records participate in version control and can be included in unlocked packages. This makes them the right choice for ISV development and any team using scratch orgs.

Code Example

// Custom Metadata Type: App_Config__mdt
// Fields:
//   - DeveloperName (built-in)
//   - Value__c (Text 255)
//   - Description__c (Text)

// Apex — no SOQL needed, cached automatically
public class AppConfig {

  public static String getValue(String key) {
    App_Config__mdt config = App_Config__mdt.getInstance(key);
    return config?.Value__c;
  }

  public static Decimal getDecimalValue(String key) {
    String val = getValue(key);
    return val != null ? Decimal.valueOf(val) : null;
  }

  // Usage in trigger handler:
  public static void checkApprovalThreshold(Opportunity opp) {
    Decimal threshold = AppConfig.getDecimalValue(
      'Approval_Threshold'
    );
    if (opp.Amount > threshold) {
      // Submit for approval
    }
  }
}

// In Flows:
// $CustomMetadata.App_Config__mdt.Approval_Threshold.Value__c

// In Validation Rules:
// $CustomMetadata.App_Config__mdt.Max_Discount_Pct.Value__c

Need this implemented in your org?

I've shipped these patterns in production for 10+ years.

View Consulting →

Enjoyed this? Get more like it.

Glen's Musings — AI, investing, and building things. Occasional. Free.

More Apex Tips