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
eddieeddie 

Does upsert with relationships have a problem with self joins?

I'm trying to use upsert with relationships to set Contact.ReportsToId to the external id of an existing contact using the partner WSDL.

 

The xml for my relationship field looks like this:

<Contact>

   <type>Contact</type>

   <ExternalId__c>1234</ExternalId__c> 

</Contact>

 

The API returns the following error:

No such column 'Contact' on entity 'contact'

 

This same code works correctly to set the relationship for Contact.AccountId.

 

Any ideas?

 

Thanks,

 

Eddie

SuperfellSuperfell
The containing element should be the name of the relationship, not its type, try

<ReportsTo>

   <type>Contact</type>

   <ExternalId__c>1234</ExternalId__c> 

</ReportsTo>

 


quadossquadoss

Hi Guys,

 

I'm trying to send the information asbelow

 

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Header>
        <SessionHeader xmlns="urn:partner.soap.sforce.com">
            <sessionId>00DC0000000Q7aa!ARgAQDfAAZRfroD40e5MvYwArzSzlHZybQi1ZnLckwrjK891rzh77LlkmKkToz2bKP1aG2VVwylUJYeyM2ea6prtiHzrCGkP</sessionId>
        </SessionHeader>
    </S:Header>
    <S:Body>
        <ns3:upsert xmlns:ns3="urn:partner.soap.sforce.com"
            xmlns:ns2="urn:sobject.partner.soap.sforce.com"
            xmlns="urn:fault.partner.soap.sforce.com">
            <ns3:externalIDFieldName>Id</ns3:externalIDFieldName>
            <ns3:sObjects>
                <ns2:type>Contact</ns2:type>
                <ns2:Id xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
                <ns2:LastName>TestMahesh</ns2:LastName>
                <ns2:ReportsToId>
                    <ns2:type>Contact</ns2:type>
                    <ns2:Fk_Contact__c>1234567</ns2:Fk_Contact__c>
                  </ns2:ReportsToId>
            </ns3:sObjects>
        </ns3:upsert>
    </S:Body>
</S:Envelope>

 

But I get the below soap faul.  

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Client</faultcode>
         <faultstring>Unexpected element {urn:sobject.partner.soap.sforce.com}type during simple type deserialization</faultstring>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>

 

 

Please let me know if I'm doing any mistake in passing the data.

quadossquadoss

Sent the message too soon.  the referencing structure should be

 

 <ns2:ReportsTo>
                    <ns2:type>Contact</ns2:type>
                    <ns2:Fk_Contact__c>1234567</ns2:Fk_Contact__c>
</ns2:ReportsTo>

 

and not

 

 <ns2:ReportsToId>
                    <ns2:type>Contact</ns2:type>
                    <ns2:Fk_Contact__c>1234567</ns2:Fk_Contact__c>
</ns2:ReportsToId>