Loading

Error 'You have reached the maximum number of 15 object references' when creating a new formula

Data pubblicazione: Oct 13, 2022
Descrizione


When you create a new formula (in a Formula Field, Field Update or Validation Rule), you may get the following error or something similar:

You have reached the maximum number of 15 object references on ObjectName
You must remove at least 1 relationship(s) in order to save this Formula Field.
Related objects referenced in this Formula Field:  

  • LookupField1__r
  • LookupField2__r
  • LookupField3__r
Risoluzione


This error occurs because you have reached the limit of spanning relationships (also known as cross-object reference) per object.
 

What is a Spanning Relationship?

Objects can be related to each other via a Relationship Field. When objects are related to each other, Formula Fields can reference fields on those other objects.

For example:

  • There is a custom object called Object1
  • There is another custom object called Object2
  • Object1 has a lookup relationship with Object2
  • When creating formula fields on Object1, fields on Object2 can be referenced via the Lookup

A Formula that references a field on another object is known as a Spanning Relationship.

The limit of spanning relationships per object is 15.
This means that an object can only contain up to 15 different object references.

This count is based on the number of unique relationships referenced in formulas in the following components of an object:

  • Formula Fields
  • Workflow Rules and Field Updates
  • Approval Processes
  • Validation Rules
  • Assignment Rules
  • Escalation Rules
  • Auto-Response Rules
  • Lookup Filters

Note: Self-reference lookup relationships are considered a "different" object when counting the number of spanning relationships. For example, if there's a lookup on the account object looking up to itself and it's used in a formula, it will count as another spanning relationship.
 

Spanning Relationship Examples

For these examples, assume the following:

  • There are 16 custom objects (Object1 - Object16)
  • Custom object 1 has a lookup relationship with all the 16 remaining objects


One Spanning Relationship
When creating a formula on Object1, reference another object, like this:
LookupObject1__r.Amount + LookupObject1__r.Discount / LookupObject1__r.Tax

In this example, three fields are referenced on an object via a single Lookup.  Because each of these fields is referenced via a single Lookup, this is considered one Spanning Relationship.  If the same object were referenced via a different Lookup, it would be considered a separate Spanning Relationship.


Three spanning relationships
When creating a formula on Object1, reference another object, like this:
LookupObject1__r.Amount + LookupObject2__r.Discount / LookupObject3__r.Tax + LookupObject3__r.Tip - LookupObject3__r.Total

Although there are five fields here, only three objects are being referenced (Object1, Object2, Object3).  This would be considered three Spanning Relationships.


Four spanning relationships 
First, create a Formula Field like this:
LookupObject1__r.Amount + LookupObject2__r.Discount

Next, create a validation rule that looks like this:
ISBLANK(LookupObject3__r.Amount) &&  LookupObject4__r.Discount < 145

In this case, each of these object references is its own Spanning Relationship.  The formula field references two Objects (Object1 and Object2) and is thus two Spanning Relationships.  The Validation Rule references a different two Objects (Object3 and Object4), adding another two Spanning Relationships.  This brings the total for both of these formulae to four Spanning Relationships


Other Quick Examples:
Given the above examples as a guide, there are a number of ways to reach the Spanning Relationship limit, including the following:

  • 16 formula fields, each referencing a unique object
  • 8 formula fields, each referencing a unique object, plus a workflow field update that references 8 different objects
  • A Validation Rule that references 5 unique objects, a field update that references 6 other objects, and a formula field that references 5 other objects 
  • Any combination of References that exceeds 15 across all formulas in Formula Fields, Workflow Rules and Field Updates, Approval Processes, Validation Rules, Assignment Rules, Escalation Rules, and Auto-Response Rules

 

Spanning Relationship Errors

When the limit of Spanning Relationships is exceeded, the error message will give more information about the offending Objects, references, and formulas.

Specifically, the error will show the total references being used (and by which field) in the yellow section of the error.  Note that the error also indicates the type of formula where each of these references is contained (e.g. "Formula Field", "Validation Rule", etc). 

To fix this error, simply reduce the number of references being made in the current field, or the other referenced fields to below the maximum limit of 15.

 

Viewing the Current Spanning Relationship Usage

There are two methods to check the current number of Spanning Relationships on an Object:

  1. Create a Formula Field which uses multiple Cross-Object references in an attempt to exceed the limit.  Use the error message generated when the formula is saved to determine the actual usage.
  2. Manually count the number of Cross-Object references within each formula field, Workflow Rule, and Validation Rule on the object.

 

Related Articles

Increasing the Spanning Relationships Limit

Numero articolo Knowledge

000383053

 
Caricamento
Salesforce Help | Article