SOAP XSL Integration error during upsert: “cannot specify Id”

errorintegrationsoapupsert

Below is an example of the SOAP request that is being sent to Salesforce from our app.

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Header>
        <SessionHeader xmlns="urn:partner.soap.sforce.com">
            <sessionId>...</sessionId>
        </SessionHeader>
        <CallOptions xmlns="urn:partner.soap.sforce.com">
            <client>...</client>
            <defaultNamespace>...</defaultNamespace>
        </CallOptions>
    </soap:Header>
    <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        <upsert xmlns="urn:partner.soap.sforce.com">
            <externalIDFieldName>CPQ_External_Id__c</externalIDFieldName>
            <sObjects xmlns="urn:sobject.partner.soap.sforce.com">
                ...
                <CPQ_External_Id__c>123456</CPQ_External_Id__c>
                <Transaction_ID__c>123456</Transaction_ID__c>
                <Id>some_id</Id>
                <Start_Upserting_Lines__c>true</Start_Upserting_Lines__c>
            </sObjects>
        </upsert>
    </soap:Body>
</soap:Envelope>

But we receive the following error, which btw I'm not sure in which part of the communication is happening:

Could not perform Action: Save
During commerce integration Process ID: …, Name: Lightning Quote Upsert
Exception occurred for Integration Process ID: …, Name: Lightning Quote Upsert
cannot specify Id in an insert call

However, in the SOAP example I see there is a tag for upserting lines that is set to true, and also the whole content of the body it's surrounded by the upsert tag as well.

Have you ever seen an error like this?

Thanks for your time.

Best Answer

When you're using an External ID field, you are not allowed to specify <Id> as well. You need to remove the <Id> from the upsert() call to make it work.

Related Topic