Salesforce’s record-triggered flows have revolutionized the automation landscape, offering a seamless, declarative approach to triggering business processes from record changes. But as every Salesforce professional knows, business requirements fluctuate, and having the agility to turn this automation on or off swiftly is crucial. Enter Custom Metadata Types, a hidden gem that can serve as an on-off switch for your automation. This post will guide you through using Custom Metadata Types within record-triggered flows to control your Salesforce automation.
Understanding Custom Metadata Types
Before diving in, it’s vital to grasp what Custom Metadata Types (CMDTs) are. CMDTs in Salesforce are similar to custom objects, but they store data that informs the behavior of your org’s processes rather than the data about your business. The beauty of CMDTs is that they allow admins and developers to create highly configurable apps that can be updated without altering code or, in our case, adjusting flows directly.
Why Use CMDTs in Record-Triggered Flows? The primary advantage is adaptability. Business rules change, and you might need to pause certain automations during certain events. Instead of deactivating the entire flow (and later remembering to reactivate it), you can use CMDTs to “switch off” the automation. When you’re ready to resume, switch it back on — all without modifying the flow.
How to Implement the On-Off Switch
Now, let’s explore how to set this up step-by-step:
1. Create a Custom Metadata Type:
- Navigate to Setup, and in the Quick Find box, enter “Custom Metadata Types.”
- Click “New Custom Metadata Type” and give it a label, such as “Flow Switch” (Switch__mdt).
- After creating the CMDT, you must add fields the flow will reference. For instance, create a checkbox field called “All Switch”, “Flow1 Switch”, “Flow2 Switch” etc. (All_Switch__c and Flow1_Switch__c)
2. Add Records to the Custom Metadata Type:
- Once your CMDT is set up, it’s time to create a new record. This record acts as the control setting for your flows. In my case, I named this single record Master.
- All Switch will turn on-off all automation while Flow1 Switch will control only Flow number 1.


3. Adjust Your Record-Triggered Flows:
- Here is the new magic: You don’t need to get your CMDT anymore in flow to use it. You can refer to the values by using the correct syntax in your start element formula conditions and formula resources. The preferred method is to add them to the start element entry formula conditions.
- The syntax you need to use here will depend on your CMDT naming and field labels, but it will look very similar to this:
$CustomMetadata.Switch__mdt.Master.All_Switch__c
$CustomMetadata.Switch__mdt.Master.Flow1_Switch__c
*Please note that Switch_mdt is the label of the CMDT, Master is the label of the single record followed by the field name.
4. Testing Your Setup:
- Thorough testing is crucial. Adjust the CMDT records and observe if the flows behave as expected. They should only proceed when “Is Active” is true and stop when false.
5. Maintenance and Updates:
- When you need to turn a flow on or off, update the checkbox fields in the CMDT record. There’s no need to adjust or deactivate the flows, ensuring your configurations remain intact.
Leveraging Custom Metadata Types to control your record-triggered flows is not just a smart move; it’s a strategic approach to maintain scalable, dynamic, and adaptable Salesforce automation. This method protects the integrity of your flows, reduces the risk of errors during off-and-on transitions, and saves significant admin time. Most importantly, it provides the agility your business needs to adapt to changing requirements with grace and efficiency. So, flip the switch on your record-triggered flows with confidence, knowing that Custom Metadata Types have got you covered!
Recommended offsite reading: Architecting for Flexible Automation Execution