In large organisations with many users, data loss is likely to happen. This can occur when multiple users are updating the same record, which means that the changes one user makes can get overwritten by another user.
Imagine two users receive customer support tickets from customers and take actions by retrieving and updating these tickets using a desktop application. Both users open the same Ticket record and one of them updated it by increasing the Priority Level field. The other user took a little bit longer to update the record. When the second user submitted his/her changes, all submitted data by the first user are lost. Dynamics CRM 2015 Online Update 1 addresses this issue for update or delete requests by setting the concurrency behaviour.
The Entity class has a new property called RowVersion, which is set when a record is retrieved from CRM. This property is of type “long” and is increased each time you update a record.
The following code snippet illustrates the use of the RowVersion property. We first retrieve a ticket record from CRM and then update the record.
You set the UpdateRequest as below:
When you execute the UpdateRequest, CRM compares the row version. If it doesn’t match, the CRM platform will throw an error.
I’ve written a sample Console Application and ran two instances to retrieve and update the same record.
If you want to deliberately take the latest changes, then use AlwaysOverwrite.
For more information about how to use this enum in other contexts like plugins or workflows, check the MSDN documentation here.