Friday, April 01, 2011 3:52 PMIs there any direct way to execute a group of creates/updates as a transaction in CRM 2011? Specifically, I want to perform a series of creates/updates and roll them all back if any of them fails. I was planning on create an entity called transaction_createupdateaction that has a string property with that contains a serialized list of entities to create or update and registering a pre plugin that deserializes and runs them. Then a post plugin that deletes the transaction_createupdateaction record. Will this work or is this a bad idea Is there a cleaner way to run transactions in CRM?
Friday, April 01, 2011 4:57 PMModerator
CRM has no support for user initiated transactions. There is a fundamental reason why not; if CRM did support user-initiated transactions then it would have to be possible to rollback changes, and for full consistency, this would mean that changes made by any plugin on the entities affected would also have to be rolled back, which could only be done if all plugins supported a two-phase commit model, which isn't going to happen.
If you are certain that none of your changes will cause other plugins or workflows to fire, then you could use a mechanism like the one you describe. However, you have no control over locking, so you still couldn't be certain that a user would see some of your changes, which you might then roll back
Microsoft CRM MVP - http://mscrmuk.blogspot.com http://www.excitation.co.uk
- Marked As Answer by Chris the CRM User Friday, April 01, 2011 5:06 PM
Friday, April 01, 2011 5:39 PMThanks for the answer. If I was sure that the plugins registered on the other entities only performed validation or created/updated other entity records using the CRM Service from IServiceProvider, would I be safe using the described mechanism in order to perform rollbacks?