knowledgecenter-breadcrum

Knowledge Center

24 Jun, 2021

How to prevent multiple users from modifying the same record at the same time programmatically?

Posted on 24 Jun, 2021 by Admin, Posted in Dynamics 365

How to prevent multiple users from modifying the same record at the same time programmatically? Blogs

How to prevent multiple users from modifying the same record at the same time programmatically?

Introduction

As we know, Dynamics CRM is used by multiple users. So the possibility of modifying the same record at a time is very high. This can result into inconsistent data.

Solution

We can avoid this with the help of concurrency control mechanism using RowVersion property.

Example

Below is a code implementing concurrency control mechanism:-

Now, if the name of the record is changed in CRM at the same time by a different user, before UpdateRequest is executed. Then, service.Execute() will give an Exception: “The version of the existing record doesn’t match the RowVersion property provided.” and it would not be executed successfully.

If you want to forcibly perform the Update operation through code, then, simply change this line as mentioned below:

updateReq.ConcurrencyBehavior = ConcurrencyBehavior.AlwaysOverwrite;

In the same way, concurrency control can be maintained, while deleting the record using DeleteRequest as mentioned below:

 

Comment

This is a Required Field

Loading

Recent Updates

Thumbnail_top 10 benefits of
Blogs
02 Dec, 2024

Top 10 Benefits of Microsoft Dynamics 365

This blog lists the advantages of Microsoft Dynamics 365, focusing on how it can improve your business operations.    …

READ MORE
Thumbnail_Microsoft365 Vs D365
Blogs
12 Nov, 2024

Microsoft 365 vs Dynamics 365

This blog will help you understand the key difference between Microsoft 365 and Dynamics 365, so you can make an…

READ MORE
Thumbnail_What is Microsoft Dynamics 365
Blogs
05 Nov, 2024

What is Microsoft Dynamics 365?

This blog explores Microsoft Dynamics 365, a cloud solution for handling different business activities smoothly. The rising trends of competition…

READ MORE