Choose your path Increase your proficiency with the Dynamics 365 applications that you already use and learn more about the apps that interest you. Up your game with a learning path tailored to today's Dynamics 365 masterminds and designed to prepare you for industry-recognized Microsoft certifications.
Visit Microsoft Learn
2020 release wave 1 Discover the latest updates and new features to Dynamics 365 planned through September 2020
Release overview guides and videos Release Plan | Preview 2020 Release Wave 1 Timeline
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
I'm trying to enforce the optimistic concurrency control for changes done via UI. To accomplish this I've created a plugin which is triggered in the Update message (Pre-operation stage) and sets the ConcurrencyBehavior setting to IfRowVersionMatches.
In theory, this should work smoothly but it actually does not. After some tests I've found that the RowVersion property is always null:
Without the RowVersion, CRM can't compare the entity being updated with the current version of the record so the validation is never triggered.
I know that this feature is something relatively new (MSND states "Optimistic concurrency behavior can only be set through an SDK call. There is presently no setting for it in a form of the Web application.") but I would expect that at least it should be possible to access the RowVersion from the plugin context and force this behaviour.
I've read about some issues related the RowVersion in the context of a (sandboxed) plugin so I'd like to know if this is a known problem or possible workarounds.
According to the documentation that you provided you have to retrieve the entity. You are not retrieving entity, you are using "Target" object in a plugin, which is not the same (target is passed to the plugin in the context and does not contain all the information that resides in the entity). Try to Retrieve this entity in this plugin - RowVersion should be filled.
Why don't you try post image?
Hi Pawel, I'm trying to force the optimistic concurrency control for updates being done via User Interface so it does not make sense to retrieve the entity in the plugin (the RowVersion could be different). Actually, the Retrieve of the entity was performed by CRM when it loaded the form, so it doesn't seem too crazy to assume that the RowVersion attribute should be there.
I can't see the relation here - ok CRM retrieves the entity on the form, but it does not pass this to the target. In target you have only fields you changed and some mandatory fields so it has no relationship with the entity that was retrieved for the form. If this would be so easy there would not be the statement that this is not working on the form (in the link you provided). I can't see any nice answer here, looks like this is not going to work in this scenario, maybe somebody else has some more ideas.
Hi again Pawel,
Yes, I know that probably there's no nice answer/solution and that's why I was asking if this a know issue or a limitation. In previous releases there were some bugs related to the RowVersion from plugin context (even using the Retrieve method) and it seemed possible that some of those issues are still there. Basically the problem is the one that you described, the RowVersion is not being passed to the Target and in my opinion that's something that should happen (it should be one of those "mandatory fields" of your message, it's not an attribute). Maybe it's just a matter of waiting for this feature to be fully implemented...
In the meantime, I've found that it's possible to access the RowVersion from the client side using the following:
I'll play a little bit to see if it's possible to implement a workaround using this.
Please let us know how it went, this may be some interesting feature
I'm seeing this in CRM 2016 on-prem as well. I have a plugin that generates a custom ID for an entity. I have a non-sandbox, synchronous, pre-validation plugin that fires on-create. It retrieves a 'last used ID' from another entity, increments it and saves back the updated 'last used ID'. I was trying to use the RowVersion property to ensure another instance hadn't updated the 'last used ID' before I tried to update it, but RowVersion is empty every time. I've double-checked the metadata to be sure that IsOptimisticConcurrencyEnabled is set to true for the entity that I'm trying to get RowVersion.
My workaround was to lock the part of my plugin that retrieves, increments, and re-saves the last used ID as a critical section (C# lock statement). Unfortunately, Fede, I don't think this applies to your situation, but maybe it will spark some ideas or help someone else that comes across this post.
Business Applications communities