Upsert

Updates or inserts an object from external data.

Salesforce inserts or updates a record depending on whether the external ID currently exists in the external ID field. To force Salesforce to create a new record, set the name of the external ID field to “Id” and the external ID to null.

Parameters 

  • API version (string, optional)
  • Object type (string)
  • External ID field (string)
  • External ID (string, optional)
  • Fields (map, optional)—Maps each field name to an object containing its value

If fields is null, the upserted record is empty.

iOS 

Swift

1RestClient.shared.requestForUpsert(withObjectType:externalIdField:externalId:fields:)
Objective-C

1- (SFRestRequest *)requestForUpsertWithObjectType:(NSString *)objectType
2                                externalIdField:(NSString *)externalIdField
3                                     externalId:(nullable NSString *)externalId
4                                          fields:(NSDictionary<NSString*, id> *)fields
5                                       apiVersion:(nullable NSString *)apiVersion;

Android 

Kotlin

1fun getRequestForUpsert(apiVersion: String?, objectType: String?,
2    externalIdField: String?, externalId: String?,
3    fields: Map<String?, Any?>?): RestRequest
Java

1public static RestRequest getRequestForUpsert(String apiVersion,
2    String objectType, String externalIdField, String externalId,
3    Map<String, Object> fields)

See Also 

We've Moved

Welcome to the new home of the Mobile SDK Developer Guide! For now, the Japanese guide can be found in PDF form.