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
Gavin ChinGavin Chin 

Assistance Required: Error on Upsert invalid field...external id

Hi All,
I have contacts(updates and new) from an external system which i need to send over to Salesforce(SF) via SOAP. I have created a field (IFCS_c) as an external id with the intention to use this as part of the upsert so that SF will either create a new contact or update an existing contact. At the same time if it is a new contact i need to associate it to an existing Account record object using AccountId field in Contact. The external id field name is set to IFCS_c. The upsert for contact WSDL is as below:
  <urn:externalIDFieldName>IFCS__c</urn:externalIDFieldName>
  <urn:sObjects xsi:type="Contact" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <urn:AccountId>001S000000nbmnsIAA</urn:AccountId>
    <urn:IFCS__c>1741</urn:IFCS__c>
    <urn:Contact_Type__c>Card Delivery</urn:Contact_Type__c>
    <urn:MailingStreet/>
    <urn:OtherStreet/>
    <urn:FirstName>Bob Tester</urn:FirstName>
    <urn:LastName>Bob Tester</urn:LastName>
    <urn:Primary__c>false</urn:Primary__c>
  </urn:sObjects>
</urn:upsert>

I am getting the following message:
<con1:ReceivedFaultDetail xmlns:con1="http://www.bea.com/wli/sb/stages/transform/config">
      <con1:faultcode xmlns:urn="urn:fault.enterprise.soap.sforce.com">urn:INVALID_FIELD</con1:faultcode>
      <con1:faultstring>INVALID_FIELD: Field name provided, IFCS__c does not match an External ID for Contact</con1:faultstring>
      <con1:detail>
        <sf:InvalidFieldFault xsi:type="sf:InvalidFieldFault" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <sf:exceptionCode>INVALID_FIELD</sf:exceptionCode>
          <sf:exceptionMessage>Field name provided, IFCS__c does not match an External ID for Contact</sf:exceptionMessage>
          <sf:row>-1</sf:row>                                                                                      
          <sf:column>-1</sf:column>
        </sf:InvalidFieldFault>
      </con1:detail>
      <con1:http-response-code>500</con1:http-response-code>

 Any help will be great and thanks in advance.
Sunil02KumarSunil02Kumar
Hi Gavin,

This might be issue with field level security of IFCS__c field for user which is used to upsert contact. 

Thanks,
Sunil Kumar
Anupam RastogiAnupam Rastogi
Hi Gavin,

If for a moment I ignore the fact that you wish to relate a contact to an Account as well, the upsert should work. Few things - 

 - Please make sure that you have created field IFCS__c in Contact object
 - Please make sure that this field is created as an external field

In my app, a working message is similar to yours as shown below - 
      <urn:upsert>
         <urn:externalIDFieldName>Siebel_Id__c</urn:externalIDFieldName>
         <urn:sObjects xsi:type="urn1:Account">
            <Industry>Banking</Industry>
            <Type>Prospect</Type>
            <Siebel_Id__c>1-AC0A7</Siebel_Id__c>
         </urn:sObjects>
         <urn:sObjects xsi:type="urn1:Account">
            <Name>Test Account Sample 9</Name>
            <Siebel_Id__c>1-AC0A8</Siebel_Id__c>
            <Industry>Agriculture</Industry>
            <Type>Other</Type>
         </urn:sObjects>
      </urn:upsert>

Otherwise I do not find any reason for this error to occur.

Secondly, regarding relating a Contact to an existing Account - Relationships in salesforce are created using the relationship names. So to relate an object with another you need to use the relationship name like shown below - 
 
<urn:sObjects xsi:type="urn1:Contact">
   <FirstName>Anupam7</FirstName>
   <LastName>Rastogi7</LastName>
   <urn1:Account>
      <Siebel_Id__c>1234574</Siebel_Id__c>
   </urn1:Account>
</urn:sObjects>

Moreover you need to use an external Id field on the related to object for establishing this relationship.

So in your case, you wish to relate Contact with Account. So do the following - 

1. Create a new external Id field on Account
2. Data Load the external system Account Ids in this newly created external Id field
3. Use this field in the SOAP message (as shown below 'Siebel_Id__c' is an external Id field on the Account object in my app)

For now to test it, you can just create a new external Id field on Account, give it a dummy value for an Account, use it in the SOAP message that you are sending. This should create a new Contact that is related to this Account.

Thanks
AR

If you find this reply useful that solves your problem then please mark it as best answer.