0

I have a scenario where i need to perform create opertion.I have imported the Enterprise salesforce wsdl and trying to perform create operation on a junction object.

I have a junction object slaesOrgProductLink that has a master detail relation to Product__c and lookup to slaesOrg__c.I am trying to insert the junction object slaesOrgProductLink using the external id of the 2 masters.however i am unable to understand whats going wrong.

Can anyone please help?

below is my soap 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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Header>      
      <urn:SessionHeader>
         <urn:sessionId>**session id stuff**</urn:sessionId>
      </urn:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <urn:create>         
         <urn:sObjects xsi:type="urn1:SalesOrgProductLink__c">            
            <urn:Product__c xsi:type="urn1:SalesOrgProductLink__c"> 
           <urn:Product_Id__c>000000000000100050</urn:Product_Id__c>
           </urn:Product__c>
           <urn:Sales_Org__c xsi:type="urn1:Sales_Org__c">  
           <urn:Sales_Org_Name__c>SFDC</urn:Sales_Org_Name__c>
           </urn:Sales_Org__c>           
         </urn:sObjects>
      </urn:create>
   </soapenv:Body>
</soapenv:Envelope>
0

You're close, but product__c is the name of the ForeignKey field (i.e. the column that holds the 18 char salesforce Id of the related row), product__r is the name of the relationship (i.e. a materialization of the related row). To use externalIds for FK resolution, you need to specify the relationship, not the FK name (because you are providing the related object, not its PK), so you need.

<urn:sObjects xsi:type="urn1:SalesOrgProductLink__c">            
   <urn:Product__r xsi:type="urn1:SalesOrgProductLink__c"> 
     <urn:Product_Id__c>000000000000100050</urn:Product_Id__c>
   </urn:Product__r>
   <urn:Sales_Org__r xsi:type="urn1:Sales_Org__c">  
     <urn:Sales_Org_Name__c>SFDC</urn:Sales_Org_Name__c>
  </urn:Sales_Org__r>
</urn:sObjects>

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.