Upsert Method – CRM 2015 Update 1


There is a new method named Upsert is introduced which will come handy when we are working data.

Upsert = Update or Insert.

This reduces the complexity of data operation. In situations we may not know that we should update or insert as we are not sure.

By using Upsert method,

 UpsertRequest request = new UpsertRequest() { Target = account };
 UpsertResponse response = (UpsertResponse)service.Execute(request);

Understanding the Upsert process

The following steps describe the processing logic when an UpsertRequest is received:

  1. Send UpsertRequest with enough data for a create or insert operation.
  2. CRM will look up the record targeted by the target entity.
  3. If the record already exists,
    1. Set the ID property of the target entity with the ID of the found record.
    2. Call Update.
    3. Set the RecordCreated to false
    4. Create an EntityReference from the target entity of the update as the value for Target
    5. Return the UpsertResponse
  4. If the record does not exist
    1. Copy any alternate key values into the target entity attributes.
    2. Call Create.
    3. Set the RecordCreated to true
    4. Create an EntityReference from the target entity type and the ID result of the Create request as the value for Target.
    5. Return the UpsertResponse

    For more information:—Upsert

    Thank you,

    Sreeni Pavalla


Published by Sreeni Pavalla

Working as a Assistant Technical Manager in Positive Edge Technologies. Having over 11 years of extensive hands-on experience in MS Dynamics CRM 4.0, 2011, 2013, 2015, 2016, Dynamics 365 with over 5 years of experience in CRM Online. You can visit my blog here

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: