Loading
Enhance Salesforce with Code
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Reference Custom Metadata Type Records in Default Values

          Reference Custom Metadata Type Records in Default Values

          Default field values make your users more productive and decrease errors by reducing the number of fields to fill in manually. Reference a custom metadata type record in a default value. If a default field value changes, you can update it in the custom metadata type instead of updating multiple field references.

          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
          Example Let’s say that your organization applies different discount rates to opportunities. Here’s how you create the custom metadata field value.
          • Create a custom metadata type. In this example, we name it DiscountPercent.
          • Create a custom field for your type named discount.
          • Create a record, and name it IT.
          • Create a custom field on the Opportunities object, and name it Discount Rate.
          Note
          Note The formula editor doesn’t include custom metadata field types. Reference the custom metadata field value manually. The TEXT() function for picklists isn’t supported.

          When done, you can reference the custom metadata field value as a default value to populate the Discount Rate field. The syntax is:

          $CustomMetadata.CustomMetadataTypeAPIName.RecordAPIName.FieldAPIName

          Use the correct suffixes. For the custom metadata type, use __mdt. For fields, use __c. Records require no suffix. Our example looks like this:

          $CustomMetadata.DiscountPercent__mdt.IT.discount__c

          When the maximum discount amount changes, you can make the update in one location.

          Tip
          Tip Remember that users can override default values if you don’t make the field settings read-only.
           
          Loading
          Salesforce Help | Article