Efficient data entry
Dynamics 365 encourages users to manage their data concurrently. Users can view and update records even while their colleagues are modifying the very same records. This is in contrast to the old days of Excel sheets being locked when in use by another user. But what happens when two users access the same record and update it at the same time?
The challenges of concurrency
Since CRM 2015 Update 1, Dynamics 365 has supported optimistic concurrency, which is detailed in this blog post.
"The idea is simple, the entities now have a property called RowVersion (auto incremental number) which stores the retrieved version of the record. When an Update or Delete request is executed (and the ConcurrencyBehavior has been explicitly configured), Dynamics 365 will compare if the record RowVersion is the same than the one stored in the database and rollback the operation if they're not."
However, this feature is only available through the SDK, and can't be added with basic form customisations. Some developers have found an internal function to access the RowVersion property, but because the function isn't documented by Microsoft, it isn't supported.
So to answer the initial question: when two users update the same record at the same time, the resulting record in the database is a combination of both records. However, if both users updated the same field, then the database will store the value entered last. The user who hit save a few seconds before would therefore lose their data.
Overcoming the challenges
With reference to this post I've offered two potential solutions, though these require either C# code or unsupported JavaScript.I'd like to offer an alternative approach which is lightweight, configurable, supported and requires no code to setup.
Introducing get-along.js.
Get Along is a small, documented tool which can be installed in any Dynamics 365 environment and configured to notify users when a record they're viewing is modified by someone else. For developers, the installation is as simple as:
- Downloading Get Along from its GitHub page.
- Adding a single script file to the relevant form (i.e. Contact or Account).
- Registering an
onLoad
event handler.
At the time of writing, the project is new and only supports an information-style notification banner to users. The project has a backlog of new features on the way, including:
- Configurable alert dialog boxes with buttons as a choice rather than notification banners.
- Configurable notification text displayed to users.
- Hopefully more added by contributors (the project is open source).
Wrapping up
Being notified of changes elsewhere isn't always desired behaviour. Users might want to be left alone to manage their data, and could be well aware that other users are tinkering with the same records.
However, sometimes data loss on forms is a problem for businesses.
- A process within the business might dictate that only one user should be updating a record at one time.
- Form logic might execute on update of certain fields, that all users should be made aware of. Because form logic is client-side, users will not see this change unless they're notified to refresh the record.
- Users may be used to notification behaviour if they use other collaboration tools such as Microsoft Excel Online or Confluence.
There are solutions available such as introducing optimistic concurrency which, as we've explored, can either be complex or require unsupported code.
Get Along offers a lightweight, configurable and supported solution to data loss. The project is open source and has a backlog of new features in the pipeline which will grow to support further configuration.
nice
ReplyDelete