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
KSKumaarKSKumaar 

Creating related records having a parent-child relationship using the create() in SOAP API

I am very new to SOAP API integration in salesforce.

I am unable to create related records having parent-child relationships. To get some awareness about this process, i gone through Force.com SOAP API Sample WSDL Structures page, here i got some information about Creating related records having a parent-child relationship using the create() API.

But this XML contains <Siebel_Id__c>1-HR68E</Siebel_Id__c> tag which is not understandable by me. Full XML is given below:
<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>[sessionId retrieved from the login() call]</urn:sessionId>
    </urn:SessionHeader>
  </soapenv:Header>
  <soapenv:Body>
    <urn:create>
      <urn:sObjects xsi:type="urn1:Account">
        <Name>Sample Account Two</Name>
        <!-- Siebel_Id__c is the External Id field present on Account object -->
        <Siebel_Id__c>1-HR68E</Siebel_Id__c>
      </urn:sObjects>
      <urn:sObjects xsi:type="urn1:Contact">
        <FirstName>Anupam</FirstName>
        <LastName>Rastogi</LastName>
        <urn1:Account>
          <Siebel_Id__c>1-HR68E</Siebel_Id__c>
        </urn1:Account>
      </urn:sObjects>
    </urn:create>
  </soapenv:Body>
</soapenv:Envelope>

This XML is saying Siebel_Id__c is the External Id field present on Account object.
What is External Id field in Account? How can I use this field in XML?
Best Answer chosen by KSKumaar
KSKumaarKSKumaar
I got answer for this 

While creating a field, in step number 2 you will get an external ID Checkbox. Click the checkbox and save that field. Use this field in XML as follows
 
<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>[sessionId retrieved from the login() call]</urn:sessionId>
    </urn:SessionHeader>
  </soapenv:Header>
  <soapenv:Body>
    <urn:create>
      <urn:sObjects xsi:type="urn1:Account">
        <Name>Sample Account Two</Name?
        <External_Id__c>1-HR68E</External_Id__c>
      </urn:sObjects>
      <urn:sObjects xsi:type="urn1:Contact">
        <FirstName>Anupam</FirstName>
        <LastName>Rastogi</LastName>
        <urn1:Account>
          <External_Id__c>1-HR68E</External_Id__c>
        </urn1:Account>
      </urn:sObjects>
    </urn:create>
  </soapenv:Body>
</soapenv:Envelope>

For more clarifications see the below picture how i created

User-added image