Why hardcoding in Flow is a risk
Building a complex Salesforce Flow, it is easy to drop IDs, record type names or status strings straight into decision nodes and assignment elements. Those "magic strings" break when you move between environments, sandbox to production, because record IDs change and configuration names drift.
Store the configuration in Custom Metadata Types
Custom Metadata Types (CMT) hold configuration data efficiently. CMT records deploy through Change Sets or DevOps pipelines (SFDX), which Custom Settings records do not, and that makes them a good fit for environment-specific configuration.
Implementation steps
- Create a new Custom Metadata Type, for example
Flow_Configuration__mdt. - Add fields for the data you change often: email addresses, user IDs, environment-specific thresholds.
- Fetch the metadata with a Get Records element. CMT is cached, so this is fast and does not count against your SOQL governor limits the way a standard object query does.
Example: dynamic email routing
Rather than hardcoding a support email in your Flow's Send Email action, store it in a metadata record.
- Create a record in
Flow_Configuration__mdtnamedSupport_Email_Config. - Add a Get Records element to your Flow, with the Object set to
Flow_Configuration__mdtand the filterDeveloperName Equals Support_Email_Config. - Map the field value from the record variable directly into the Recipient Address field of your action.
Performance considerations
Salesforce caches Custom Metadata records at the application level, so your Flow runtime retrieves these values with minimal latency. And because CMT queries are treated differently from standard record queries, they are a good way to keep automation inside execution limits while the logic stays configuration-driven.
Leave a Comment