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
chch 

Sales Force Update object Failed: attempt to violate hierarchy constraints

Hi all.

 

We have a PHP web app talking to SF.  We have converted a Lead to an Account, and are then trying to update the account and getting the error when playing in the sandbox:

Sales Force Update object Failed: attempt to violate hierarchy constraints

 

Unfortunately, there's no documentation on this error anywhere, and it seems like we're the only ones getting it.

 

Can anyone shed some light on what this means?  The same code works fine when talking to the live SalesForce.

 

Thanks

Todd

 

kvinkvin

Hey Todd, did you have any success with this. If so can you please share your thoughts. I saw this error today and I'm lost as what could have lead to this.

msimondsmsimonds

Is it possible that the ID's are different in your Sandbox environment?  I believe that they are, but I could totally be off base with this and wrong

SuperfellSuperfell

It sounds like you're trying to create a circular account hierarchy, and that's not allows (e.g.  account 1's parent is account 2, account 2 parent is account 3, and then trying to set account 3 parent to be account 1).

cropzimcropzim

I can confirm (having run into this error today):

 

  • Let's say you have an Account with custom lookup field Related_Account__c that is a lookup to Account and ...
  • In Apex, you have a reference myAccount to an Account....
  • and you set myAccount.related_account__c = myAccount.id
  • and do an Update DML operation

You'll get the error

 

I imagine this is true for any SObject and in DML insert, update, and upsert operations

VaszVasz
I guess you are trying to add a self relationship. EX: For AccountA, you are trying to Link AccountA as its Parent.