Employ Validation Rule Formulas with Custom Metadata Types (Pilot)

If you use validation rules, you know how helpful they can be, but you have to hard code some of the values. Now you can store values you previously had to hard code in custom metadata types and reference them in your validation rules.


Use a validation rule formula to limit discounts on certain brands to 10%. You can use validation rules without custom metadata. However, to change an amount, you must update the hardcoded value. If you have multiple validation rules that check the discount amount, you have to manage all of them. Instead, use a validation rule formula with custom metadata types.

  1. Create a custom metadata type. In this example, we named it DiscountLimits.
  2. Create a custom field for your type. We named it maxDiscount.
  3. Create a record. We named it FoodDiscount.
When done, you can reference the custom metadata type in your validation rule. The syntax is:
Make sure to 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 something like this:
Discount > $CustomMetadata.DiscountLimits__mdt.FoodDiscount.maxDiscount__c