Upserting data into Salesforce using Web Service API

Upserting data into Salesforce using Web Service API

To upsert data in Salesforce using external application, upsert
() method is used.

upsert()

Creates new records and updates existing records; uses a custom
field to determine the presence of existing records. In most cases, we
recommend that you use upsert () instead of
create() to avoid creating
unwanted duplicate records (idempotent). You can process records for one more
than object type in an create() or update()
call, but all records must have the same object type in an upsert ()
call.
Upsert is a merging of the words insert and update. This call is
available for objects if the object has an external ID field or a field with
the
idLookup field property. On custom objects,
this call uses an indexed custom field called an external ID to determine
whether to create a new record or update an existing record. On standard
objects, this call can use the name of any field with the
idLookup field property instead
of the external ID.
Note:

Starting with API version 15.0, if you specify a value for a field
that contains a string, and the value is too big for the field, the call fails
and an error is returned. In previous versions of the API the value was
truncated and the call succeeded. If you wish to keep the old behavior with
versions 15.0 and later, use
the AllowFieldTruncationHeader SOAP header.
Syntax

UpsertResult[]
= connection.upsert(String externalIdFieldName, sObject[] sObjects);




Cheers!!!

Leave a Reply