Custom metadata types (CMDT) in Salesforce are a powerful tool for managing application configurations and customizations without needing code deployment. This capability is handy for many use cases. For instance, you can set parameters using custom metadata and use them in your flow. On the other hand, it is possible to use custom metadata to toggle features on and off. This provides administrators and developers a flexible and scalable solution to manage application behaviors.
How to Use Custom Metadata Types in Flow
It is possible to use the Get Records element to find the custom metadata types in flow. Then, just like any other object, you can use them throughout the flow.
For instance, let's say that you have a custom metadata type that stores the maximum opportunity amount. We can then create a record-triggered flow that automatically submits an opportunity for approval if its amount exceeds this threshold.
To achieve this, first use a Get Records element to retrieve the maximum opportunity amount value from the custom metadata type. Then add a Decision element to check whether the opportunity's amount is greater than the threshold.
How to Use Custom Metadata Types without Get
Unlike custom labels or custom settings, there is no option to use custom metadata types as a global variable. However, it is possible to use custom metadata types in flow without the Get Records element. You don't need to get the custom metadata in flow anymore. You can refer to it in your flow start element formula editor. The resource picker currently does not display custom metadata types as a choice, but this functionality is expected to be available soon.
The format that you need to use:
{!$CustomMetadata.APINameoftheCMDT.APINameoftheSpecificCMDT.APINameoftheField}
For instance;
{!$CustomMetadata.Opportunity_Settings__mdt.Approval_Settings.Maximum_Amount__c}
By using the custom metadata type in the flow entry conditions, you can make the flow run only if the amount exceeds the threshold. So that you won't need to use a Get Records element.
Another common use case is using a custom metadata type as a flow on-off switch.
Using CMDTs as an on-off switch in Salesforce Flow provides several advantages:
- Flexibility: Easily turn features on or off without modifying the flow.
- Scalability: Manage multiple features across various flows using CMDTs.
- Control: Centralize feature toggles, making it easier to manage application behavior. This can also include Apex (code) triggers.
Read this post on Salesforce Break for more details.
Fantastic article, Thank you!