---
schema_version: "1"
id: ba7101170339a0a257aaad57478849e45af3ebe0ea527b2d43794ea5a8108e90
title: UpsertResult Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_DataSource_UpsertResult.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_UpsertResult.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 657618c3820fe37ce153a458a3ef7ead8df98bec8a31df5d9fe66786998736f6
description: Represents the result of an upsert operation on an external object record. The result is returned by the upsertRows method of the DataSource.Connection class.The error message that’s generated by a failed upsert operation.The unique identifier of a row that represents an external object record to upsert.Indicates whether a delete operation succeeded or failed.Maintains the integrity of lists of type UpsertResult by determining the equality of external object records in a list. This method is dynamic and is based on the equals method in Java.Creates an upsert result that indicates the failure of a delete request for a given external ID.Maintains the integrity of lists of type UpsertResult by determining the uniqueness of the external object records in a list.Creates a delete result that indicates the successful completion of an upsert request for a given external ID.
---
# UpsertResult Class

Represents the result of an upsert operation on an external object record. The result is returned by the upsertRows method of the DataSource.Connection class.

## Namespace

[DataSource](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_DataSource.htm "The DataSource namespace provides the classes for the Apex Connector Framework. Use the Apex Connector Framework to develop a custom adapter for Salesforce Connect. Then connect your Salesforce organization to any data anywhere via the Salesforce Connect custom adapter.")

## Usage

An upsert operation on external object records generates an array of objects of type DataSource.UpsertResult. Its methods create result records that indicate whether the upsert operation succeeded or failed.

- **[UpsertResult Properties](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_UpsertResult.htm#apex_DataSource_UpsertResult_properties)**
- **[UpsertResult Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_UpsertResult.htm#apex_DataSource_UpsertResult_methods)**

## UpsertResult Properties

The following are properties for UpsertResult.

- **[errorMessage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_UpsertResult.htm#apex_DataSource_UpsertResult_errorMessage)**  
    The error message that’s generated by a failed upsert operation.
- **[externalId](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_UpsertResult.htm#apex_DataSource_UpsertResult_externalId)**  
    The unique identifier of a row that represents an external object record to upsert.
- **[success](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_UpsertResult.htm#apex_DataSource_UpsertResult_success2)**  
    Indicates whether a delete operation succeeded or failed.

### errorMessage

The error message that’s generated by a failed upsert operation.

#### Signature

public String errorMessage {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### externalId

The unique identifier of a row that represents an external object record to upsert.

#### Signature

public String externalId {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### success

Indicates whether a delete operation succeeded or failed.

#### Signature

public Boolean success {get; set;}

#### Property Value

Type: [Boolean](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")

## UpsertResult Methods

The following are methods for UpsertResult.

- **[equals(obj)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_UpsertResult.htm#apex_DataSource_UpsertResult_equals)**  
    Maintains the integrity of lists of type UpsertResult by determining the equality of external object records in a list. This method is dynamic and is based on the equals method in Java.
- **[failure(externalId, errorMessage)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_UpsertResult.htm#apex_DataSource_UpsertResult_failure)**  
    Creates an upsert result that indicates the failure of a delete request for a given external ID.
- **[hashCode()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_UpsertResult.htm#apex_DataSource_UpsertResult_hashCode)**  
    Maintains the integrity of lists of type UpsertResult by determining the uniqueness of the external object records in a list.
- **[success(externalId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_UpsertResult.htm#apex_DataSource_UpsertResult_success)**  
    Creates a delete result that indicates the successful completion of an upsert request for a given external ID.

### equals(obj)

Maintains the integrity of lists of type UpsertResult by determining the equality of external object records in a list. This method is dynamic and is based on the equals method in Java.

#### Signature

public Boolean equals(Object obj)

#### Parameters

- **obj**:
    
    Type:
    
    Object External object whose key is to be validated.

#### Return Value

Type: [Boolean](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")

### failure(externalId, errorMessage)

Creates an upsert result that indicates the failure of a delete request for a given external ID.

#### Signature

public static DataSource.UpsertResult failure(String externalId, String errorMessage)

#### Parameters

- **externalId**:
    
    Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.") The external ID of the record to upsert.
- **errorMessage**:
    
    Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")
    
    The reason the upsert operation failed.

#### Return Value

Type: [DataSource.UpsertResult](#apex_class_DataSource_UpsertResult "Represents the result of an upsert operation on an external object record. The result is returned by the upsertRows method of the DataSource.Connection class.")

Status result for the upsert operation.

### hashCode()

Maintains the integrity of lists of type UpsertResult by determining the uniqueness of the external object records in a list.

#### Signature

public Integer hashCode()

#### Return Value

Type: [Integer](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_integer.htm#apex_methods_system_integer "Contains methods for the Integer primitive data type.")

### success(externalId)

Creates a delete result that indicates the successful completion of an upsert request for a given external ID.

#### Signature

public static DataSource.UpsertResult success(String externalId)

#### Parameters

- **externalId**:
    
    Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")
    
    The unique identifier of the external object record to upsert.

#### Return Value

Type: [DataSource.UpsertResult](#apex_class_DataSource_UpsertResult "Represents the result of an upsert operation on an external object record. The result is returned by the upsertRows method of the DataSource.Connection class.")

Status result of the upsert operation for the external object record with the given external ID.