When attempting to update a client’s formula field on an object, I received an uncommon error message. Salesforce complained, “You have reached the maximum number of object references”.

This error is caused by trying to exceed the limit of cross-object references (also known as “spanning relationships”). It seems that Salesforce decided objects can only have 15 or less spanning relationships.

This limit is based on the number of unique relationships referenced in formulas in formula fields, field updates, approval processes, validation rules, assignment rules, escalation rules, and auto-response rules

To be clear, if object A refers to object B more than once, it’s still considered to be one spanning relationship. However if object A refers to object B and C, then those are two spanning relationships.

While this limit may never be reached on smaller instances, it can cause quite a commotion for larger ones.

So how do you resolve this?

Firstly, being aware of this type of limitation is helpful. Don’t build formula fields without this consideration.

Secondly, consider the following:

  • Are there other ways of exposing data in formula fields that could work?
  • Could a junction object work?
  • Does the formula span multiple levels of a hierarchy? See if it’s possible to flatten the hierarchy

The takeaway
Be aware of the maximum number of cross-reference formula fields. When all else fails, you can open a case with Salesforce to have this limit increased from 15 to 20.

Category:
Salesforce