function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aziz KarakhanyanAziz Karakhanyan 

How to increase number of allowed formula references fields in a scratch org

When I attempt to push metadata to my scratch org, I get this error.
The formula references fields across 16 relationships while only 15 are allowed. Please contact support at for more assistance.

There are salesforce help documents  ( that explain how to increase this limit (up to 20) for a sandbox/production org, but I can't find any documentation on how to increase this for a scratch org.

Having to contact support to increase the limit on a scratch org is not a suitable answer as scratch orgs are meant to be quick and easy to spin up development environments, that would run completely counter to that.

Is there a scratch org configuration value that I can't find that would increase the number of formula references I can have? I've tried including
in my scratch org definition file (used 10 for the value), but that didn't work. I don't think that scratch org feature is related to spanning relationships.
AbhishekAbhishek (Salesforce Developers) 

For that, you have to reach salesforce support.

You can raise a ticket without premier support too.

If it helps mark it as the best answer.

Aziz KarakhanyanAziz Karakhanyan
Every time I create a scratch org I will need to contact support? That can't be the answer long term, this has got to be considered a sfdx bug.
AbhishekAbhishek (Salesforce Developers) 
It depends on the license too.

Please contact support for official confirmation.
Malika Pathak 9Malika Pathak 9
Hi Aziz,
Please contact salesforce support.
Frans Flippo 14Frans Flippo 14
I'm running into the same issue. I've logged a case with Salesforce Support and will post the results of that here.
Frans Flippo 14Frans Flippo 14
It hardly comes as a surprise, but this was Salesforce Support's answer:
I went through your case and I understand that you would like to increase the spanning relationship limit on a scratch org.

I regret to inform you that increasing this in a Scratch org is not possible at this point of time due to the product limitation.

I hope you understand that limitation and kindly go through the below article where it doesn't mention the limit to increase this spanning relationship.

Scratch Org Features

Please let me know if you have any further concerns and I will be happy to assist you further.

Funny how all the talk about "customer success" seems to just silence the minute you have an actual problem with Salesforce's products...
Aziz KarakhanyanAziz Karakhanyan

Hey Frans and others who reach this post,

Besides just spanning relationships, there are other features/limits that you may have in your production or full copy sandbox orgs that you can't replicate in your scratch orgs. Some of those things are:

1. Spanning relationships
2. Workflow limits
3. Processes on an object

There are many more. The highest edition of a scratch org you can make right now is enterprise, whose limits are less than unlimited or what your specific production org has.

It's something I've been struggling a lot with since attempting to create our first salesforce package using SFDX.

Something recently that has helped a ton actually, has been using the Org Shape beta feature. In essence, it uses your production org as the scratch org template. Additionally, this feature has access to APIs and limits that we can't define ourselves. By using org shape, I was able to have an unlimited edition scratch org, which increased my limit for workflows, processes on custom object. I was also able to deploy fields now with spanning relationships > 15.

My suggestion to those struggling with the limits imposed by scratch orgs is to try to use the Org Shape beta feature. It allows you to make scratch orgs with limits you can't do yourself. 

Frans Flippo 14Frans Flippo 14
Thanks Aziz, that is really helpful! So the org shape only determines the features and limits of the org, not the metadata? So it will still be an empty org, just like a regular scratch org?
Aziz KarakhanyanAziz Karakhanyan
Yes, that's right Frans. The documentation for the Org Shape feature is pretty solid. You can find it here.