Custom Metadata Types and Validation Rule Formulas
Use custom metadata records to store validation rule record values.
Then, reference the records directly within validation rules and eliminate the need to add the
same values into different validation rules. Using packaging? You can define the logic and
leave customization to a subscriber.
Required Editions
Available in: Salesforce Classic and Lightning Experience
Available in: Enterprise, Performance, Unlimited, and
Developer Editions
You can create, edit, and delete custom metadata type
records from installed packages in: Group and Professional
Editions
Example Consider a validation rule that limits the discount on a brand to 10 percent. When you
apply a change in the discount, values within the validation rule need updating. With multiple
rules that check the discount amount, you must update all rules. By using custom metadata
records within these validation rules, you simply update the discount amount within the custom
metadata record without modifying any of the validation rules.
Create a custom metadata type. In this example, the custom metadata type is named
DiscountLimits.
Create a custom field for your type named maxDiscount.
Create a record and name it FoodDiscount.
When done, you can reference the custom metadata record in your validation rule. The
syntax
is:
Use
the correct suffixes. For the custom metadata type, use __mdt. For fields, use __c. Records require
no suffix. Your validation rule for this example looks like
this:
You
can also use the insert field dialog to reference custom metadata records within a
validation rule. In Setup, go to management settings for the relevant object.
We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required Cookies
Always Active
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional Cookies
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising Cookies
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.