Merge Fields for Validation Rules

A merge field is a field you can put in an email template, mail merge template, custom link, or formula to incorporate values from a record.

Required Editions

Available in: both Salesforce Classic and Lightning Experience
Available in: Essentials, Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions

Syntax and Formatting

When you insert a merge field in a validation rule, the syntax consists of the object, a period, and the field name. For example, $User.State corresponds with a user’s state or province.

A merge field’s syntax can vary depending on where you’re using the field. To make sure you’re using the correct syntax, select merge fields from the drop-down list in the editor where you’re using the merge field. The merge fields for validation rules correspond directly with the fields in your app.

For a list of fields in an object, from the management settings for the object, go to the fields section.

Important
Important
  • If two or more custom objects have matching names or labels, only one of the objects appears when you select from available merge fields. Make sure that all custom objects have unique names and labels so that you can select merge fields from any of the objects.

Limitations

Validation rules can’t reference merge fields for:

  • Auto number fields, such as Requisition Number
  • Compound fields, such as addresses, first and last names, dependent picklists, and dependent lookups
    Note
    Note Validation rules can reference merge fields individual address fields, such as Billing City.
  • Campaign statistic fields, including statistics for individual campaigns and campaign hierarchies

Tips

  • Some merge fields display as radio buttons but function like picklist fields when referenced in a formula.

    Use the values “Read,” “Edit,” and “None” in a formula when referencing:

    • $UserRole.CaseAccessForAccountOwner
    • $UserRole.OpportunityAccessForAccountOwner
    • CaseAccessLevel (on Territory)
    • OpportunityAccessLevel (on Territory)

    Use the values “Read,” “Edit,” and “All” in a formula when referencing:

    • AccountAccessLevel (on Territory)
  • Use the RecordType.Id merge field in your formula to apply different validations for different record types.