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

Blogs
07 Sep, 2023

Optimizing Storage with SubscriptionTrackingDeletedObject Cleanup

What is SubscriptionTrackingDeletedObject? The "SubscriptionTrackingDeletedObject" table is linked to the "DeletionService," which handles two types of cleanup: organization-wide and record-specific.…

READ MORE
Blogs
05 Sep, 2023

How to create real-time customer journeys in Dynamics 365 Marketing

Introduction: This blog will show how to create real-time customer journeys in Dynamics 365 Marketing. Customer journeys can be either…

READ MORE
Blogs
30 Aug, 2023

D365 CUSTOMER SERVICE: CUSTOMER 360 COMPONENT

Introduction: In Dynamics 365 (D365) Customer Service, the 'Customer 360' Component provides a comprehensive view of information and enables users…

READ MORE