web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Nishant Rana’s Weblog / Sample Code to use UpsertRe...

Sample Code to use UpsertRequest in CRM 2015\2016

Nishant Rana Profile Picture Nishant Rana 11,325 Microsoft Employee

UpsertRequest was a new request introduced in CRM 2015 Online Update 1.

The request based on the alternate key specified, looks for the record, if the record is existing it updates it else it creates a new record.

https://nishantrana.wordpress.com/2016/10/25/alternate-keys-in-crm-2015crm-2016/

UpsertResponse has a property named RecordCreated which is false if the record is found and updated else it is true if record is created. The Target property holds the reference of the record created or updated.

Suppose we have following record created. It has Alternate key defined on “Alternate Key Field”

Sample Code

As we have demo entity record with alternate key field having value as “My Alternate Key 1” it will update the record.

Running it again this time changing the value for the alternate key field.

It creates a new record.

Hope it helps..


Filed under: CRM, CRM 2015, CRM 2016, Microsoft Dynamics CRM Tagged: CRM, CRM 2015, CRM 2016, CRM 2016 Update 1, Microsoft Dynamics CRM

This was originally posted here.

Comments

*This post is locked for comments