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
pcroadkillpcroadkill 

upsert call creating duplicate accounts

I have a java program that gets data from or BI system and then either merges the data with an existing salesforce account record or creates a new one. When I submit the upsert call using the Id as the key, my expectation was that the records that contain an Id will be updated and the ones that don't, will be created. It seems that it always creates new records therefore creating duplicates.

I have read that the upsert api doc and refers to an externalId, but I have not found anything that states how to use the actual Object id as the key. In the REST api doc and DML guides say to leave the key blank and it will use the object id, but in the SOAP API I don't seem to be able to do that.

Any help will bre greatly appreciated.
BalajiRanganathanBalajiRanganathan
Try passing the value "Id" instead of empty. it should work
pcroadkillpcroadkill
I am doing that and it is creating duplicates. I tried the blank key after noticing the duplicates and the API thoriws an error. My riginal code has Id as the key and everytime I run it it creates duplicates.
BalajiRanganathanBalajiRanganathan
Are you passing value (15 digit id) or Name. it should be just the string "Id"
pcroadkillpcroadkill
The key coming back from Salesforce is 18 digits long. I've read that this is to make it case-safe and it states that it can be used wilth all API calls.
BalajiRanganathanBalajiRanganathan
My question is, are u doing this
connection.upsert( "Id", sobject);
or 
connection.upsert( "<18digitid>", sobject);