Reached the maximum number of 15 object references for formula - apex trigger? - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Cloud SolutionsCloud Solutions 

Reached the maximum number of 15 object references for formula - apex trigger?

Hello everyone,

I was adding a few formula fields to my custom object which got information from related custom objects.  However when trying to save the field an error message was displayed : You have reached the maximum number of 15 object references on ObjectName

The field is required to get information from a related object 2/3 objects away..

I have already requested Salesforce to increase the limit but have been told 15 is the max they can go.

As a workaround I have attempted to write my first trigger. In this scenario would this be my only choice?  

I have considered the following but none of them really would work other than an apex trigger imo.:

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.
Geoffrey FlynnGeoffrey Flynn
That limit is always a pleasant surprise when you hit it.  I can try and provide a few ideas.
  1. I always like to purposely break it if I know I'm getting close so that I can see the references that are causing the issue.  There is often a legacy formula field/workflow criteria/validation rule that I can get rid of
  2. I try to limit the number of User, Profile, and Record Type references where possible.  These can get messy and take up a lot of your references very quickly.  Just validating on RecordType.DeveloperName takes 2 up right off the bat.
  3. Take a look at Process Builder.  This should be able to push that value down to the lower objects without requiring a formula.  The balance of course is that a record edit needs to cause this.  Again I would go back to what are the references and see what is applicable.  User fields like Role, Account fields like address are both great examples of where this would work well
  4. See if the fields are really required on the Page Layout, or if they can just be added to Custom Report Types through the Lookup area.  Many people aren't aware of thisUser-added image
  5. Lastly of course is to write a trigger.  I've had to do it before, but I try really hard to get around it first
@ShannonHale provided some good insight here that I used recently to get back under the limit
https://success.salesforce.com/ideaView?id=08730000000gKsbAAE

This idea is under consideration as well
https://success.salesforce.com/ideaView?id=08730000000hDO6AAM
Vote it up

Hope that helps