Merge Fields for Cross-Object Formulas

A Cross-object formula is a formula that spans two related objects and references merge fields on those objects.

Required Editions

Important
Important Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.
Available in: Salesforce Classic
Available in: all editions

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.

A cross-object formula can reference merge fields from a master (“parent”) object if an object is on the detail side of a master-detail relationship. A cross-object formula also works with lookup relationships. For example, you can write a cross-object formula that references the Account Name for a contact associated with a case. In this example, you would type Contact.Account.Name in a formula on the Case object.

Syntax and Formatting

Merge fields for formulas aren’t enclosed in curly braces or preceded by an exclamation point. Use the relationship names of the objects, not the labels. Although the relationship name is often the same as the object name, it is technically the field name of the relationship field.

To reference the parent account name from Account object, the syntax is Parent.Name, not Account.Name. When referencing a custom object, add two underscores and the letter r to its name. For example, Position__r.title__c references the Job Title field (title__c) on a Position custom object.

Limitations

You can’t reference:

  • Merge fields for objects related to activities. For example, merge fields for contacts and accounts are not available in task and event formulas.
  • The $RecordType global variable—it only resolves to the record containing the formula, not the record to which the formula spans. Starting with the Spring ’13 release, when you create a new formula the $RecordType global variable is only available for default value formulas.

The value of the Profile.Name merge field differs depending on the context of the cross-object formula field that references it. On detail pages, the value is the profile name, as expected. In list views and reports, the value is the internal value of the associated profile instead. If you use Profile.Name in a formula, use it within an OR function to ensure that the formula always returns the intended result. For example:

IF
     (OR
          (LastModifiedBy.Profile.Name = "Standard User", LastModifiedBy.Profile.Name = "PT2"), 
     "Standard", "Not Standard")

None of the above applies to profile names referenced by the $Profile global variable.