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
Anand Prakash TiwariAnand Prakash Tiwari 

Hierarchy Constraint Violation not working for Child record

I am having a lookup field for the same object (self lookup)
As per salesforce, we should receive following error if any record tries to make self as a parent or tries to choose any of the child record as a parent.

Hierarchy Constraint Violation
You cannot set a hierarchy field Parent Hotel to point to itself or a child record.

But, I am not getting this error if I am making a circular hierarchy, as described below -
  1. If making same record as parent of any record (record parent of self during edit) , A->A. then getting thsi error. This is good.
   2. If A -> B->A, then It is not giving error.

Could you please help, if there is any configuration for enabling to restrict circular dependency from clild?


Regards,
Anand
Sonam_SFDCSonam_SFDC
Hi Anand,

As explained in the h&T doc:

Self Relationships
You can create a relationship from an object to itself, but it must be a lookup relationship, and a single record can't be linked to itself. However, a record can indirectly relate to itself. For example, the Holiday Promotion campaign can have the Direct Mail campaign selected in the lookup relationship, and the Direct Mail campaign can have the Holiday Promotion campaign selected in the lookup relationship.
You can't create a many-to-many self relationship, that is, the two master-detail relationships on the junction object can't have the same master object.

So for custom objects - such elf lookup will not give you an error, however, the error is applicable for the standard Parent Account field on Account

reference: http://help.salesforce.com/HTViewHelpDoc?id=relationships_considerations.htm&language=en_U
Dea73Dea73
I have a similar question/issue. I have created a junction object to itself and i have noticed that when trying to link a parent project to a child object the lookup field turns into a dropdownlist and shows multiple projects. Is there a different way to resolve this issue?