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
Rick_NookIndRick_NookInd 

Record with a lookup to itself... Impossible?

I'm trying to populate a lookup to Account in Account called Parent_or_Self_Id__c, but it generates an error when I set a record to reference itself:

Hierarchy Constraint Violation in the UI

or

CIRCULAR_DEPENDENCY, attempt to violate hierarchy constraints in Apex

 

From a Data Model and a practical perspective it's much preferred to have one lookup field than potentially sixty-five cross object formulas (if that's even allowed) to pull the data from the parent record defaulting with the current record.

 

Anyone know if the apparent check restricting circular references in the data can be disabled by the SalesForce feature activation customer support?  I called a different area of customer support and the person seemed to be under the assumption that it couldn't be changed without any reasoning why.

 

Perhaps the validation rule was created by a salesforce developer over-protecting the system so he could guarantee no infinate loops ever?  In theory poorly coded Apex especially triggers could be following lookups in the data and get lost in an infinate loop.  But in practice, if that happened it would violate a governor rule, and generate an API error with no harm.   I can't think of any other reason to restrict data from having circular references.  Perhaps there is more reasoning to this restriction that I'm not aware of?

 

I keep running into all of these different ways that SalesForce is crippled... perhaps one per month!  So disappointing!  Another item to add to the list of technical flaws in SalesForce that maybe I can get someone to listen to at the next DreamForce?  SalesForce may be one of the least flawed Content Management Systems (CMS), but that's why experienced people often caution against CMS instead of custom programming because of those things you need done that can't be done!

 

Wayne_ClarkWayne_Clark

Hey, did you ever find a solution to this?

Rick_NookIndRick_NookInd

No.

 

It's just a Force.com flaw as far as I know.