Print this page

Understanding Spanning Relationships

Knowledge Article Number 000006372
Description

Upon creating a new formula (in a formula field, field update or validation rule), you might get an error similar to the following:

You have reached the maximum number of 10 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
 
Resolution

You receive this error 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, you can create formulas that reference fields on the other object. For example:

  • You have a custom object called Object1
  • You have another custom object called Object2
  • Object1 has a lookup relationship with Object2
  • When creating formula fields on Object1, you can reference fields found on Object2
A formula that references a field on another object is known as a spanning relationship. 

Example - One spanning relationship

For example, assume you have the following scenario:

  • You have 12 custom objects(Object1, Object2 Object3 ,Object4, Object5 ,etc.)
  • Custom object 1 has a lookup relationship with all the 11 remaining objects

When creating a formula on Object1, you are allowed to reference another object, like this:

LookupObject5__r.Amount + LookupObject5__r.Discount / LookupObject5__r.Tax

How many spanning relationships do we have?

Here, although you are referencing the same object 3 times, this is considered as ONE spanning relationship. This only holds true if you are referencing the same object via the same lookup. If you drill into a second lookup, even if it points to the same object, it will then count as TWO spanning relationships.


Example - Three spanning relationships

For example, assume you have the following scenario:

  • You have 12 custom objects(Object1, Object2 Object3 ,Object4, Object5 ,etc.)
  • Custom object 1 has a lookup relationship with all the 11 remaining objects

When creating a formula on Object1, you are allowed to reference another object, like this:

LookupObject5__r.Amount + LookupObject3__r.Discount / LookupObject4__r.Tax + LookupObject4__r.Tip - LookupObject4__r.Total

How many spanning relationships do we have?

Here, although there are 5 fields being referenced, only three different objects are being referenced (Object5, Object3 and Object4). This is considered as three spanning relationships.

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

The 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 update actions

  • approval processes

  • validation rules

  • assignment rules

  • escalation rules

  • auto-response rules
     

Please note self-reference lookup relationships are considered a "different" object when counting the number of spanning relationships. For example, if you have a lookup on the account object, looking up to itself and you use this relationship field in a formula, it will count as another spanning relationship.

Example - Four spanning relationships 
 

For example, assume you have the following scenario:

  • You have 12 custom objects(Object1, Object2 Object3 ,Object4, Object5 ,etc.)
  • Custom object 1 has a lookup relationship with all the 11 remaining objects

You create a formula field that looks like this:

LookupObject5__r.Amount + LookupObject3__r.Discount

Then you create a validation rule that looks like this:

ISBLANK(LookupObject6__r.Amount) &&  LookupObject8__r.Discount < 145

How many spanning relationships do we have?

Here, the first formula field references two unique objects (Object 5 and Object3). The validation rule also references two unique objects (Object6 and Object8).

In this case, the Object1 object has four spanning relationships, since the combination of the formula field and the validation rule references four different objects.


Different ways of hitting the limit

With the above examples in mind, you can reach the spanning relationship limit in many different ways, including:

  • You have 10 formula fields and each formula references a unique object
  • You have 5 formula fields and each formula references a unique object. You then create a workflow field update that references 5 different objects.
  • You have a validation rule that references 3 unique objects, a field update that references 4 other objects and a formula field that references 3 other objects. 
  • Any combination of the above.

Understanding formula errors related to spanning relationships

Example 1 - Formula field contains more than 10 object references

User-added image



The error seen above, has a list of the relationship fields (in this case lookup fields) that are being referenced in the formula field that you are creating.

Example 2 - One formula field has 8 object references. A new formula being created contains 3 object references, hitting the limit of 10 references per object. 

User-added image


The error above shows that 3 unique objects are being referenced on the new formula field however, another formula field (called test) already references 8 different objects.

Example 3 - Same as the above but one additional formula field already exists.

User-added image


This specific error can sometimes be misleading. The error message shows all the object references on this particular object, but it doesn't mean that all the fields being shown, count as an additional reference.

For example, you will see that the field Test references Object9. Then, the formula field called Test2 also references Object9. This is considered as one spanning relationship. With this, it is important that you understand that if an error message shows the same object multiple times, this only constitutes a single spanning relationship.

In the example above, the Object1 has 8 spanning relationships (despite the fact that the error shows 9 conflicting fields). 

In order to view the current use toward the limit of spanning relationships, we may either:
1) Create a test formula field using multiple cross-object references in an attempt to exceed the limit, and then expand the details of the error message, OR
2) Manually count the number of cross-object references within each formula field, workflow rule, and validation rule on the object 

For information about increasing the limit of spanning relationships per object, visit this article Increasing the Spanning Relationships Limit

 





promote demote