I have an org that is hitting the 10 limit of spanning relationships. I know I can up it to 15, but I think that might not be enough.

I know I could rebuild the contracts object with a junction object (I didn't build this in the first place), I'm trying to work out a way to avoid this.

I have created custom report types to get most of the data out just to view , but there are some key formulas that I can't do as I keep getting the error.

I am doing a project (with an external developer, I'm not a coder) to do a sync of the data in Salesforce with an external system sending the data to a REST API endpoint.

If the complex formulas I need are handled within the Apex class that sends the data off to the external system, will that avoid the spanning relationships errors?

The workarounds (https://help.salesforce.com/apex/HTViewSolution?id=000171213&language=en_US) say to use Triggers instead of validation rules, so that leads me to think that code does not have these restrictions?

Am I going to be OK with coding these complex formulas, or do I need to start on a redesign of the whole solution?

  • Can you post the formula? Are you trying to denormalize the data using these formulas for export? Is it possible to do multiple calls for different functional contexts? Is the datamodel over-normalized? – Peter de Jong May 26 '15 at 9:49
  • Thanks @PeterdeJong there is not one formula at the moment, probably 20 formulas, and I have not scoped them yet. I just know that every time I try to enter a slightly complex formula to retrieve something that I can not get via the report type, I come against the spanning relationships error. I will start by getting it increased to 15, then create the queries in Apex that I need. – JodieM May 28 '15 at 2:59

Spanning relationship is counted in one of the following feature:

  1. formula fields
  2. workflow rules and field update actions
  3. approval processes
  4. validation rules
  5. assignment rules
  6. escalation rules
  7. auto-response rules

one of the workaround to avoid spanning relationship is to use Apex/coding.

read this article- https://help.salesforce.com/HTViewSolution?id=000171213&language=en_US

As a workaround this clearly states :

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.

so spanning relationship are not counted when you use them in apex trigger, SOQL queries etc.

| improve this answer | |
  • Thanks, good to know I was on the right track with my thinking. I will push forward with speccing the queries in Apex. – JodieM May 28 '15 at 2:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.