Home Upsert

Upsert:

Syntax:
UpsertResult[] ur= connection.upsert(String externalIdFieldName, sObject[] sObjects);
Upsert is creates new records and updates existing records; uses a custom field to determine the presence of existing records. Use upsert() instead of create() to avoid creating unwanted duplicate records You can process records for the one more than object type in an create() or update() call, but all records must have same object type in an upsert() call.
Upsert is merging of the words insert and update. This call is available for the objects if the object has an external ID field or a field with the idLookup field property.
Select update/create:
* If external ID is not matched, then a new record is created.
* If external ID is matched once, then the existing record is updated.
* If external ID is matched multiple times, then an error is reported.
* When batch updating multiple records where the external ID is the same for two or more records in your batch call, those records will be marked as errors in the UpsertResult file. The records will be neither created nor updated.
Sample Code:
				 Post Views: 1,117