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
MattAustinMattAustin 

Help with using External ID as foreign key for Upsert call with the partner wsdl

Does anyone have a sample of what the SOAP message structure looks like for making an upsert call, with the partner wsdl, where the master record's external ID is used as the foreign key (rather than the salesforce ID)?.  I saw some examples of how to do this in code, using the enterprise wsdl, but not sure how the SOAP message looks for the partner wsdl.  I am trying to test this using XMLSpy, so I need the actual SOAP structure.
 
Here is the body of the SOAP message I currently use, but it requires the salesforce ID as the foreign key "Sales_Order__c" :
 
<SOAP-ENV:Body>
  <m:upsert xmlns:m="urn:partner.soap.sforce.com">
     <m:externalIDFieldName>ShipmentExternalID__c</m:externalIDFieldName>
     <m:sObjects>
        <m0:type>Delivery__c</m0:type>
        <m0:ShipmentExternalID__c>98765-artec</m0:ShipmentExternalID__c>
        <m0:Sales_Order__c>a0030000009RPj7AAG</m0:Sales_Order__c>
     </m:sObjects>
  </m:upsert>
 </SOAP-ENV:Body>
SuperfellSuperfell
<upsert xmlns:="urn:partner.soap.sforce.com">
<externalIDFieldName>masterId__c</externalIdFieldName>
<sObjects>
 <type>Contact</type>
 <firstName>Simon</firstName>
 <lastName>Fell</lastName>
 <masterId__c>SFELL_042</masterId__c>
 <account>
   <type>account</type>
   <duns__c>001-001-001</duns__c>
 </account>
</sObjects>
</upsert>

This upserts a contact using the masterId__c field on contact, and additional uses the duns__c field on account to resolve the relationship to account.

for your example you probably want something like

<Sales_Order__r>
  <type>Sales_Order__c</type>
  <myOrderId__c>42</myOrderId__c>
</Sales_Order__r>


MattAustinMattAustin
Fantastic!!   Thanks...  This will save me lots of code!!
Elux_SteveElux_Steve

What if I need to do a lookup based on multiple fields?  Do I just add in the 2nd field under the 1st?  It sounds logical but want to make sure.

 

thanks

Steve

Peter KempPeter Kemp

Did you ever find an answer to this? I'm not sure that you can concatenate ExternalIDfields.  The api certainly doesn't let you.  Does SOAP allow it?

 

Thanks

 

Pete

Elux_SteveElux_Steve
No sure have not but if you got some info I would like to hear it.