I created the self lookup relation field to the custom object.By using apex code while upsert the bulk of records with external id but i'm facing the following error

Line: 44, Column: 1 System.DmlException: Upsert failed. First exception on row 2; first error: CIRCULAR_DEPENDENCY, attempt to violate hierarchy constraints: [Parent_Data_Domain__c]

/......../ Error message


Please find below code and help me on this issue /...../ Self lookup relation of custom object code /....../

  • 1
    Please always include code and error messages as text, not screenshots. You can edit your question to fix this issue. – David Reed Mar 9 '20 at 13:49

Generally this means that your code has attempted to relate an object to itself, which is not allowed anywhere in Salesforce.

You'll also see this error if you attempt to create a circular hierarchy in standard objects, like Account's ParentId field. In that context, reference cycles aren't allowed at all. Reference cycles are legal with custom objects, but self-references are not.

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.