When I got my hands on the Microsoft Dynamics CRM 2013 Beta, the first thing I tried was to save two versions of the same record concurrently to check whether CRM 2013 implements any concurrency control mechanism.Unfortunately, CRM 2013 is not any different to its predecessors in this field.
Following-up from my popular post about concurrency control in CRM 2011, I’ve decided to write a new post for CRM 2013 with some updates leveraging the latest 2013 features.
What is the concurrency problem?
Systems like Dynamics CRM are built to be used by a large number of users. When two or more users are updating the same record, the last person to save the record “wins”. Dynamics CRM does not have any concurrency control mechanism to warn or stop the users from overriding other users’ changes. This can potential result in inconsistent data especially if the users are updating the same fields.
What is new in CRM 2013
CRM 2013 offers some new and exciting features that we can use to enhance the user experience. In this post, I will be leveraging the new Auto-Save and Form Notification features to display a discrete message on the form when the record has been updated elsewhere.
How to solve the problem
The idea is to call the REST services and check that the value of the ModifiedOn field. If the value is greater than when the form was loaded, then the records has been changed. When auto-saving the check will display a form notification that the records has been updated by another user. If the form is saving, then a confirmation message will appear to save or cancel the event.
How to set it up
Similarly if a user tried to close the browser a “save and close” event is triggered and a pop-up message will appear. In CRM 2013 whenever a user closes the browser a “save and close” event seems to be triggers as the “save and close” button has been removed. However this functionality does not seem to work with Chrome.