UpsertResult

The upsert() call returns an array of UpsertResult objects. Each element in the array corresponds to the sObject[] array passed as the sObjects parameter in the upsert() call. For example, the object returned in the first index in the UpsertResult array matches the object specified in the first index of the sObject[] array.

An UpsertResult object has these properties.

Name Type Description
created boolean Indicates whether the record was created (true) or updated (false).
errors Error[] If errors occurred during the call, an array of Error objects, providing the error code and description, is returned.
id ID If the call succeeded, the field contains the ID of the record that was either updated or created. If there was an error, the field is null. For more information, see ID Field Type.
success boolean Indicates whether the call succeeded (true) or not (false) for this object.

If your organization has active duplicate rules and a duplicate is detected, the UpsertResult includes an Error with a data type of DuplicateError.