CRM 2011 Plugins: Welcome to transactions !

One of the thing I hate about CRM 4.0 plugins is the inability to automatically rollback actions when an exception occurs during a business process.

To illustrate this, imagine a plugin which creates a contract, then a line of contract. If the code throws an exception during the creation of the contract line, you need to take care yourself of deleting the contract that have been created: of course, you need the contract AND the contract line, not just the contract.

In CRM 2011, you can now register your plugin in new stage (see below). That means that you can register your plugin in a transaction (if using stage 20 and 40) and whenever you plugin throws an exception, every action done during the transaction will be rollback. In our previous example, that means tha the contract will be deleted automatically by the application.

Event Stage Name Stage Number Description
Pre-Event Pre-validation 10 Stage in the pipeline for plug-ins that are to execute before the main system operation. Plug-ins registered in this stage may execute outside the database transaction.
Pre-Event Pre-operation 20 Stage in the pipeline for plug-ins that are to execute before the main system operation. Plug-ins registered in this stage are executed within the database transaction.
Post-Event Post-operation 40 Stage in the pipeline for plug-ins which are to execute after the main operation. Plug-ins registered in this stage are executed within the database transaction.
Post-Event Post-operation 50 Stage in the pipeline for plug-ins which are to execute after the main operation. Plug-ins registered in this stage may execute outside the database transaction. This stage only supports Microsoft Dynamics CRM 4.0 based plug-ins.
 
More informations on the SDK page :
 

Comments

Farshid said…
I would like to introduce a small prototype we have developed which shows how CRM 2011 transaction can be part of Enterprise transactions (DTC).

All details and sourcecode are on Codeplex:

https://crmtransaction.codeplex.com/

Please feel free to comment.

Unknown said…
This is a nice and helpful information for online crm software Service. Online crm software, Online Customer Relationship Management , CRM, sales automation, Contract management CRM . Thanks For sharing with us and keep share more blogs for us.
Anonymous said…
hi, good posting.

your post is what i want to.
could you give some example code for this case.? so we can do rollback for two transaction action.

thanks.
abbas said…
I want to add a section in plugin which I want to run Async and don't want user to hang on while it finishes as it can take up to 15 minutes(loads of inserts, updates etc.)
I know we can choose a step in plugin to Post and run as Async but this is not working.

Can you kindly kind me how I can achieve this and if any code that would be great.

Thanks
Unknown said…
I really appreciate spending some time to talk about that, I believe firmly regarding this and so really enjoy understanding more about this kind of subject.This is also a very good post which I really enjoyed reading. It is not everyday that I have the possibility to see something like this. CRM Software || MLM Software in Mumbai || ERP Software || System Software in Mumbai

Unknown said…
Keep up the fantastic piece of work, I read few blog posts on this web site and I believe that your site is real interesting and has lots of great information. ERP Software in Mumbai || System Software || CRM Software in Mumbai || MLM Software

Popular posts from this blog

New XrmToolBox plugin : Import/Export NN relationships

Searchable Propery Attribute Updater

Full featured CRM grid in HTML/JS