The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Must-read

Custom Metadata Types as one deployable home for values across Salesforce and Agentforce (opens in a new tab)

You will see how one Custom Metadata Type can feed formulas, Validation Rules, Flow, Apex and Agentforce actions, and where those references stop working.

Typed into each tool

  • Thresholds in formulas
  • Defaults in Flows
  • Feature switches in Apex classes
  • Each change means finding every use

Custom Metadata Types

  • One deployable home for values
  • Travels through source control
  • One record per region plus Default
  • Read via $CustomMetadata reference
One deployable home replaces values typed into each formula, Flow or Apex class

The article argues that developers often hard-code business values such as thresholds, defaults, feature switches and mappings into formulas, Flows and Apex without noticing, which makes later changes hard to trace. Custom Metadata Types offer a central, deployable home for these values. Unlike Custom Settings or Custom Objects, which hold data, Custom Metadata holds configuration that ships with application code through source control and CI/CD. The author illustrates this with a Deal_Policy__mdt type holding a shared maximum discount and regional records for large-deal amount, default discount and approval threshold, selected by region name.

The piece then maps where references work. Formula Fields, Validation Rules and field defaults can use a three-part reference (type, record name, field), but the formula must name a fixed record, so it cannot pick a region from opportunity data. Long text area fields cannot be referenced, and the formula editor does not list Custom Metadata fields for defaults, though typing the reference still works. Flow can query the type with Get Records, match a region, and fall back to the Default record, and it can also use the literal reference. Apex uses getInstance with a similar fallback. Custom Permissions are kept separate, since they govern what a user may do while Custom Metadata governs the values.

Agentforce cannot read $CustomMetadata references directly, so the workaround is an invocable Apex action that loads the policy and returns the values, which the Agent Script maps into variables before answering. Lightning App Builder component visibility does not accept Custom Metadata references. On record pages a Formula Field can bridge the value, though that adds a field, and App and Home pages must read the data in Apex, through @wire, or via Dynamic Interactions.

To assess impact, the article recommends Setup’s Where is this used? option or a Tooling API query of MetadataComponentDependency, which lists the Apex classes and Validation Rules that depend on a field. It also notes that an attempt to build an LWC editor that showed these dependencies from Apex was complicated by the authentication setup REST calls require. Finally, it outlines platform limits: 200 types per org (350 with certified managed packages), 100 fields per type, and a 10 million character budget where each text area reserves 255 characters regardless of use. Process Builder allows 15 Custom Metadata formula references per process. The author concludes that teams should treat business values as configuration, centralize them, and keep track of where each reference works and where it does not.

Read the original at Andy in the Cloud (opens in a new tab)

Worth reading?