Maximum of 15 object references on object name You must remove at least 1 relationships

Each Object in Salesforce is allowed to have upto 15 unique relationships with other objects.

Show

Objects can be related to other objects using a relationship field. When objects are related to each other, user can create formulas that reference fields on the other object. For instance:

  • You have a custom object called MyObject1
  • You have another custom object called MyObject2
  • MyObject1 has a lookup relationship with MyObject2
  • When creating formula fields on MyObject1, you can reference fields found on MyObject2

A formula that references a field on another object is known as a spanning relationship.

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

LookupMyObject5__r.SaleAmount + LookupMyObject5__r.FinalDiscount / LookupMyObject5__r.Tax Rate

The limit of spanning relationships per object is 15. This means, that an object, can only contain up to 15 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 keep in mind if I have Program Approver, Fiscal Approver as both Lookup(User) on any custom object, any formula using these 2 objects will consume 2 spanning relationship although it is on same Object (User)

In case you exceed maximum spanning relationship, you will get an error like this.

Maximum of 15 object references on object name You must remove at least 1 relationships

You will then have to revisit your formulas and see if it can be optimized.

Ways to Reduce Spanning Relationships

https://help.salesforce.com/articleView?id=000171213&language=en_US&type=1

Agh! the dreaded 

You have reached the maximum number of 10 object references on XXX.

You must remove at least 1 relationship(s) in order to save this Formula Field.

I HATE this error... probably even more than I HATE the dreaded 5000 Character Limit on Formulas.

So I had to investigate this more fully. 

Why it happens

  • You have a few formulas a few levels deep, (even referencing other formulas). 
    • Eg, I created a Formula on the User Object that referenced the User Role, then I wanted to show some details about that User on the Account Record (eg User.CustomFormula__c), so the Relationship on the User formula was to User Role, but on the Account it was to User then User Role. 

Examples

    • People want to do Emails, and don't want to use Visualforce Email Templates, so try to bring all the values they need to reference, onto the object they are sending the email from. Just use Visualforce Emails!
    • People want to see all related information on the same page - eg, you have an Account, and on the Contract you want to see the Account Email, the Account Primary Contact's Phone Number etc. Nope! Just use Hover Pages.
    • A complex web of lookups. Try using Workflows or Rollup Helper instead. 

Options

  • Audit - WHY are these fields in use? Are they being used? 
  • Increase the limit to 15 with a Salesforce Support ticket. 
  • Simplify your process. 
  • Workfows, Process Builder, Flows or at last resort Triggers to update the fields.
  • Use Visualforce Email Templates
  • Make a Visualforce page showing the fields for the related object and show that on the page layout under the lookup field (interestingly, Microsoft Dynamics CRM 2013+ does this very very nicely). 

Notes

Official KB Article https://help.salesforce.com/HTViewSolution?id=000006372&language=en_US

  • The limit of spanning relationships only includes references made to different objects.

One response:

  • Consider if there are other ways to expose data in formula fields. For example if you want to see information on an object 1-2 levels away on an object’s detail page but not report on it, you can require users to hover over the lookup link to view the details.
  • If you have multiple references to the same type of object (for example, you reference four different contacts in formula fields, each with a different purpose), consider creating a junction object so you can display the referenced objects in a related list.
  • If you have references that are only used in validation rules, rewrite those rules as an Apex trigger.
  • If any of the references are used by only one component, convert that to a trigger.
  • If you are spanning multiple levels of a hierarchy such as parent accounts, cases, or a hierarchy of custom objects, see if it’s possible to flatten the hierarchy.

https://success.salesforce.com/ideaView?id=08730000000hDO6AAM

Another product manager response that is good https://success.salesforce.com/ideaView?id=08730000000gKsbAAE

Be Aware! Appexchange Apps will also use up your limits! https://success.salesforce.com/answers?id=90630000000goLqAAI