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
evgenykaevgenyka 

Upsert by external Id issue

I have a problem upserting by external ID


Code:
    $createFields=array(
        'Name' => ociresult($stmt, "NAME"),
              'ORACLE_ORDER_ID__C'=> ociresult($stmt, "ORACLE_ORDER_ID__C"),
        'CUSTOMER_PARENT__C'=>ociresult($stmt, "CUSTOMER_PARENT__C"),
         'SC1__C' => ociresult($stmt, "SC1__C"),
        'BILL_TO_ACCOUNT_NAME__C' => ociresult($stmt, "BILL_TO_ACCOUNT_NAME__C"),
        'SHIP_TO_ADDRESS__C'=>ociresult($stmt, "SHIP_TO_ADDRESS__C"),
        'TERRITORY_COMISSIONS__C'=>ociresult($stmt, "TERRITORY_COMISSIONS__C"),
               'REP_COMISSIONS__C'=>ociresult($stmt, "REP_COMISSIONS__C"),
             'ACCOUNT__C'=>$SF_CUST_ID
     
       ) ;
 
  print_r ( $createFields);
     
  $sObject = new SObject();
  $external_id =  ociresult($stmt, "ORACLE_ORDER_ID__C"); 
  $sObject->fields = $createFields;
  $sObject->type = 'Order_Id__c';
  
  $createResponse = $mySforceConnection->upsert($external_id,array ($sObject));
 
  print_r ($createResponse);

When running the code i am getting the following error
Code:
Fatal error: Uncaught SoapFault exception: [sf:INVALID_FIELD] INVALID_FIELD: Field name provided, 2305 does not match an External ID for Order_Id__c in /oracle_general/SF/sforce-php/soapclient/SforceBaseClient.php:585
Stack trace:
#0 [internal function]: SoapClient->__call('upsert', Array)
#1 /oracle_general/SF/sforce-php/soapclient/SforceBaseClient.php(585): SoapClient->upsert(Object(stdClass))
#2 /oracle_general/SF/order_load.php(78): SforceBaseClient->upsert('2305', Array)
#3 {main}
  thrown in /oracle_general/SF/sforce-php/soapclient/SforceBaseClient.php on line 585

 



Same code works just fine with create or upsert by ID
Thank You


 

Message Edited by evgenyka on 05-01-2007 02:55 AM

evgenykaevgenyka
Sorry , i figured it out
Also wanted to ask in 9.0 API can i upsert by SF ID?
SuperfellSuperfell
Yes.