2

We are planning to deepen out integration between Salesforce and a third-party tool. Within the tool we have multiple accounts related to one contact. To replicate the relations between these contacts and accounts, I activated the AccountContactRelation Object in Salesforce. Now I can successfully create a relation based on a SOAP create() call which uses the external IDs to relate the records, but I can not delete such a relation in response to a change in the external system. (I use SoapUI for testing)

I tried to use this SOAP delete() request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:urn1="urn:sobject.enterprise.soap.sforce.com">
   <soapenv:Header>
      <urn:SessionHeader>
         <urn:sessionId>${#TestCase#sessionId}</urn:sessionId>
      </urn:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <urn:delete>
         <!--Zero or more repetitions:-->
         <urn:sObjects xsi:type="urn1:AccountContactRelation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <!--Zero or more repetitions:-->
            <Account>
                <Account_ExternalID__c>2648</Account_ExternalID__c>
            </Account>
            <Contact>
                <Contact_ExternalID__c>4585</Contact_ExternalID__c>
            </Contact>
         </urn:sObjects>
      </urn:delete>
   </soapenv:Body>
</soapenv:Envelope>

I get the following error message: Unexpected element {}Account during simple type deserialization

What am I doing wrong?

1

I can't answer you question with great authority, but this might help. If you look at the Object Reference for AccountContactRelation. You will see there is a StartDate, EndDate, IsActive and an IsDirect field.

There is a primary account relation IsDirect, and there are related account relations (secondary). If you remove a primary account relation, it has the effect of deleting the contact and removing all other account relations until the primary account is restored.

Your integration should only be updating the StartDate, EndDate, and IsActive fields on the AccountContactRelation records in order to remove related account relations for a Contact. If you you try to delete the Salesforce record for the AccountId (a reference field) from AccountContactRelation, you would be removing the Account from the entire object as though you were deleting it from the org which is not what you want to do (ContactID is also a reference field.)

You should think of this as though you are updating a record for the StartDate, EndDate, and IsActive fields for each Account to Contact relation that exists.

| improve this answer | |
  • Thanks for your quick response. According to your proposal is tried to update() the IsActive field but although the call is successfull this approach does not remove the relation from the corresponding related list. I was successfull when I used the delete call after querying the salesforce AccountContactRelation Id. But this only works as long as the relation is not 'direct'. If the given relation is direct I get an error message that says 'Direct relations can not be deleted'. So, I have to find a way to make another relation direct before deleting the particular one. – Dbb Jan 30 '19 at 17:02
  • That's exactly what I would expect. A direct relation is a Primary Account relationship as I mentioned in my answer. If you remove it from the contact, all other relationships are invalidated. – crmprogdev Jan 30 '19 at 17:14

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.