0

I have created a custom field on my AccountContactRelation called SurrogateId__c and I set configured it to be an External Identifier.

When I create an AccountContactRelation from an external service, a trigger performs text-extraction from the surrogate id (something like "companyIdentifier_contactIdentifier"), looks up both account and contact and set them.

This works great the first time a record with a given SurrogateId companyIdentifier_contactIdentifier is upserted, but on the second upsert my code fails:

System.DmlException: Upsert failed. First exception on row 0; first error: DUPLICATE_VALUE, This contact already has a relationship with this company.: [ContactId]

Are external ID correclty supported by AccountContactRelation? Is there another solution to this problem?

7
  • Which field have you marked as external id? If its on AccountContactRelation and also marked as unique, it will not allow multiple records having same contact and account ids.
    – Raul
    Commented Mar 12, 2017 at 10:25
  • the surrogate key is marked as external id
    – Edmondo
    Commented Mar 12, 2017 at 10:25
  • I don't see any such field here in AccountContactRelation, to get better support you should add more detail and code as well.
    – Raul
    Commented Mar 12, 2017 at 10:39
  • I mention SurrogateId twice?
    – Edmondo
    Commented Mar 12, 2017 at 10:42
  • Ah I see you edited the post and added the information. That is the standard error, which means you cannot create additional relationship between same Contact and Account. In your trigger, you would need to avoid creating relationship if it already exists.
    – Raul
    Commented Mar 12, 2017 at 14:03

1 Answer 1

1

Upsert feature does not support for few junction objects in salesforce, AccountContactRelation object is one of them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .