1

We are facing some issue during upsert, please find details below:

We have following objects:

enter image description here

and sample data for the above objects:

enter image description here

The external system is trying to upsert TankRead__c with the following :

<soapenv:Body>
    <urn:upsert>
        <urn:externalIDFieldName>SeqNo__c</urn:externalIDFieldName>        
        <urn:sObjects xsi:type="TankRead__c">                         
            <SeqNo__c>5</SeqNo__c>
            <Volume__c>100</Volume__c>
            <TankNumber__r xsi:type="Tank__c">
                <TankNumber__c>1</TankNumber__c>
            </TankNumber__r>
            <SiteID__r xsi:type="Site__c">
                <SiteID__c>1171</SiteID__c> 
            </SiteID__r>                                
        </urn:sObjects>
    </urn:upsert>
</soapenv:Body>

and getting below error:

Error: Field name provided, TankNumber__c is not an External ID or indexed field for Tank__c.

From the error it is observed that the error is because TankNumber__c is not unique(which is as per the design).But combination of TankNumber__c and SiteId gives unique value. Can you please let me know how to enforce or include TankNumber__c and Site__c combination in the request. We tried the following and failed:

<soapenv:Body>
<urn:upsert>
    <urn:externalIDFieldName>SeqNo__c</urn:externalIDFieldName>        
    <urn:sObjects xsi:type="TankRead__c">                         
        <SeqNo__c>5</SeqNo__c>
        <Volume__c>100</Volume__c>
        <TankNumber__r xsi:type="Tank__c">
            <TankNumber__c>1</TankNumber__c>
            <SiteID__r xsi:type="Site__c">
                <SiteID__c>1171</SiteID__c> 
            </SiteID__r>
        </TankNumber__r>
        <SiteID__r xsi:type="Site__c">
            <SiteID__c>1171</SiteID__c> 
        </SiteID__r>                                
    </urn:sObjects>
</urn:upsert>

Error: More than 1 field provided in an external foreign key reference in entity: Tank__c

Please let us know if there is a solution for this.

Update Even we had thought of including a new field in Tank concatenating TankNumber and Site as Unique/External Id field. For concatenated field(say TankSite) how do we set it in SOAP request?

<soapenv:Body>
<urn:upsert>
    <urn:externalIDFieldName>SeqNo__c</urn:externalIDFieldName>        
    <urn:sObjects xsi:type="TankRead__c">                         
        <SeqNo__c>5</SeqNo__c>
        <Volume__c>100</Volume__c>
        <TankNumber__r xsi:type="Tank__c">
            <TankSite__c>
                SiteID__r.SiteID__c +TankNumber__c
            </TankSite__c>
        </TankNumber__r>
        <SiteID__r xsi:type="Site__c">
            <SiteID__c>1171</SiteID__c> 
        </SiteID__r>                                
    </urn:sObjects>
</urn:upsert>

Thanks.

  • Since tank does not gave an external id field you need to use the Id of the record if you are upsetting tankread with tanknunber__r – Eric Apr 20 '17 at 6:08
1

See my comment

You can add a field to tank concatenating the number and site and set that to external id. Then populate with a WFR.

Use that in the upsert

| improve this answer | |
  • Thanks Eric, this idea came to my mind but dont know how to set it in the SOAP request, I updated post, please correct the SOAP request. ThankYou again. – Jaya Apr 20 '17 at 6:39
  • @Jaya you have to populate it with the actual values – Eric Apr 20 '17 at 12:45

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.