1
  1. I have Account with user id as external id.
  2. I have a record of Account with user id 123 created 2 months ago.
  3. I have an upsert job created through bulk API yesterday with user id as externalIdFieldName. It was trying to upsert Account with user id 123 and all the other fields.
  4. It turns out that another Account with user id 123 was created by the upsert job

Question: why another Account was created instead of updating the old record with user id 123? From my understanding, the upsert job will lookup the records with the external id. If it find one matching, it will be updated; otherwise, a new record will be created.

So in this circumstances, why a duplicate record could be created?

Code to create Bulk upsert job:

$params = array(
    "externalIdFieldName" => 'User_ID__c',
    "object" => 'Account',
    "operation" => 'upsert'
);
$path = "/services/data/v41.0/jobs/ingest";
$c = curl_init();
curl_setopt($c, CURLOPT_POST, 1);
$encodedParams = json_encode($params);
curl_setopt($c, CURLOPT_POSTFIELDS,$encodedParams);
// url will be look like csxx.salesforce.com/services/data/v41.0/jobs/ingest
curl_setopt($c, CURLOPT_URL, $this->host . $path);
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout/1000);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$header = array('Content-type: application/json', 'Authorization: Bearer '. $this->sessionId);
curl_setopt($c, CURLOPT_HTTPHEADER, $header);
data = curl_exec($c);
7
  • Is the External Id set to case-sensitive or case-insensitive? Do the values you're representing as 123 differ in case?
    – David Reed
    Commented Jun 18, 2018 at 19:44
  • @DavidReed Thanks for asking. The external id only contains digits. Does the case sensitivity still matter?
    – Vera
    Commented Jun 18, 2018 at 19:57
  • Can you share the code you use to create the Bulk API job?
    – David Reed
    Commented Jun 18, 2018 at 20:22
  • @DavidReed I was referencing this page to create Bulk API job. I'm using php so it's basically setting the cUrl opts. It's posted in the question.
    – Vera
    Commented Jun 18, 2018 at 21:36
  • 1
    is externalId defined as unique?
    – cropredy
    Commented Jun 19, 2018 at 19:00

0

You must log in to answer this question.

Browse other questions tagged .