Cannot update Closed or Cancelled Activity – Not for Admin

Hi Team,

Today have observed a strange behavior when updating the completed activity. We have written the code to update the Completed Activity in the plugin and as we always do use Admin account for our development. Everything was working at the time of development and Testing team complained that it was not working. When we have checked in detail, we found that only Admins are able to update completed activity records. We have changed our code to use Admin User Account for updating the Activity inside the plugin and it started working like a champ.

Hope this helps.

Happy 365’ing


Dynamics 365 CE – Optimistic Concurrency – Handling Concurrent Transactions

Hi Everyone,

Let’s discuss something on Optimistic Concurrency today. 

What are Concurrent Transaction?

When two or more users need to update a same record at the same time, the changes made by the last user will be saved and this results data loss. The operations performing by users on the record at the same are known as Concurrent Transactions.

In general, there are two ways to control this behavior.

1) Pessimistic Concurrency Control
When a user is modifying the data, another user can’t access the same data at same time as the access has been locked on that data.
2) Optimistic Concurrency Control
This feature provides the ability for your applications to detect whether an entity record has changed on the server in the time between when your application retrieved the record and when it tries to update or delete that record.

On all entities, you will see a OOB filed “Version Number” of type Timestamp and it gets updated by the system every time when the record updates.

In the below code, I am retrieving the record and trying to update but before updating the record using the code I am going update the record manually in CRM. The below code will throw the exception as below.

“The version of the existing record doesn’t match the RowVersion property provided.”

                // Retrieving the account record.
                Entity entAccount = crmService.Retrieve(“account”, new Guid(“4921991e-162d-ea11-a813-000d3a59f4b3”), newColumnSet(new string[] { “name” }));
                // Creating a new object and updating the account record that was retrieved above by setting Concurrency Behavior to If RowVersionMatches.
                Entity entAccountToUpdate = new Entity(“account”);
                entAccountToUpdate.Id = entAccount.Id;
                entAccountToUpdate[“name”] = “My Account Name”;
                // Setting up the Row Version.
                entAccountToUpdate.RowVersion = entAccount.RowVersion;
                UpdateRequest accountReq = new UpdateRequest()
                    Target = entAccountToUpdate,
                    ConcurrencyBehavior = ConcurrencyBehavior.IfRowVersionMatches
                UpdateResponse accountUpdateResponse = (UpdateResponse)crmService.Execute(accountReq);
            catch (FaultException fx)
                switch (fx.Detail.ErrorCode)
                    case -2147088254: // ConcurrencyVersionMismatch
                    case -2147088253: // OptimisticConcurrencyNotEnabled
                        throw new InvalidOperationException(fx.Detail.Message);
                    case -2147088243: // ConcurrencyVersionNotProvided
                        throw new ArgumentNullException(fx.Detail.Message);
                        throw fx;

Hope this helps.

Happy 365’ing