Friday, 3 May 2013


Understanding Plug-ins in MS CRM 2011

A plug-in is custom business logic (code) that you can integrate with Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online to modify or augment the standard behavior of the platform. Another way to think about plug-ins is that they are handlers for events fired by the Microsoft Dynamics CRM platform. You can subscribe, also known as registering, a plug-in to a known set of events to have your code run when the event occurs.

Plug-in will be part of Transactions and will trace the exception during execution.


• PreEvent  : Stage 10: Pre-validation

• PreEvent  : Stage 20: Pre-operation

• Core Operation : Stage 30: MainOperation

• PostEvent   : Stage 40: Post-operation

• PostEvent   : Stage 50: Post-operation (deprecated*)

Stage 20,30,40 are Transaction Scope.


Sync/Async Execution

Plugins can execute in
- Synchronously during pipeline execution

- Asynchronously – queued for later execution


Transaction Support

CRM 2011 Stages support plugin execution inside the database transaction
- Stages 20 & 40

Uncaught exceptions force a rollback
IExecutionContext.IsInTransaction
Transaction spans CRM DB operations only
- No distributed transaction support

Plugins registered outside transaction stage will participate in transaction if executed as nested pipeline of transactional parent.