Hi,
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:
- Send UpsertRequest with enough data for a create or insert operation.
- CRM will look up the record targeted by the target entity.
- If the record already exists,
- Set the ID property of the target entity with the ID of the found record.
- Call Update.
- Set the RecordCreated to false
- Create an EntityReference from the target entity of the update as the value for Target
- Return the UpsertResponse
- If the record does not exist
- Copy any alternate key values into the target entity attributes.
- Call Create.
- Set the RecordCreated to true
- Create an EntityReference from the target entity type and the ID result of the Create request as the value for Target.
- Return the UpsertResponse
For more information: http://www.kingswaysoft.com/blog/2015/04/16/New-CRM-SDK-Feature—Upsert
Thank you,
Sreeni Pavalla