Dynamics CRM 2011 Event Execution Pipeline

Leave a comment

 

By Hector Villafuerte. 

 

Hector Certifications

 

 

Dynamics CRM backend receives messages from the CRM Web application or other application that uses a CRM SDK method. These messages are being sent to the organization Web service.

These messages are passed through the event execution pipeline where it can be read or modified by the platform core operation and any registered plug-ins.

The following figure illustrates the overall architecture of the Microsoft Dynamics CRM platform with respect to both synchronous and asynchronous event processing.


 

Event Execution Pipeline

Calls to the CRM web services can execute any of these messages. Each message creates a pipeline made up of various events (Pre-Event, Core Operation and Post-Event) and Stages (Pre-validation, Pre-operation, Main-operation and Post-operation). Plug-ins can be registered on different stages in the pipeline.

The event pipeline is divided into multiple stages shown below:

Pre-validation Stage: Plug-ins registered in this stage may execute outside the database transaction.

Pre-event Stage: Plug-ins registered in this stage may execute inside the database transaction.

Core Operation: Custom Plug-ins cannot be registered in this stage.

Post-event Stage: Plug-ins registered in this stage may execute inside the database transaction.

 

When application code or a workflow invokes any of these messages, the system raises an event. The information passed as a parameter to the web service method is internally packaged up into an OrganizationRequest message and processed by the pipeline. The information in the OrganizationRequest message is passed to the first plug-in registered for that event where it can be read or modified before it is passed to the next registered plug-in for that event and so on. Plug-ins receive the message information in the form of context that is passed to their Execute method. The message is also passed to the platform core operation.


Plug-ins can be registered to execute before or after the core platform operation. Pre-event registered plug-ins receive the OrganizationRequest message first and can modify the message information before the message is passed to the core operation. After the core platform operation is complete, the message is then known as the OrganizationResponse. The response is passed to the registered post-event plug-ins. Post-event plug-ins will be able to modify the message before a copy of the response is passed to any registered asynchronous plug-ins. Finally, the response is returned to the application or workflow that invoked the original web service method call.

A pre-event registered plug-in that passes an exception back to the platform cancels the core operation, any pre-event or post event registered plug-ins that have not yet executed, and any workflow that is triggered by the same data change event that the plug-in is registered for.

Plugins can be executed synchronously during pipeline execution or Asynchronously to be queued for later execution.

Messages and entities

The possible messages and entities combinations that triggers the events can be found at SDKMessage-entity support for plug-ins.xlsx.

This excel spreadsheet has the possible Messages for the Out-of-the-box entities.


The following table display the possible messages for Custom entities:

 

Message Name

Ownership Type

Assign

User-owned entities only

Create

User-owned and organization-owned entities

Delete

User-owned and organization-owned entities

GrantAccess

User-owned entities only

ModifyAccess

User-owned entities only

Retrieve

User-owned and organization-owned entities

RetrieveMultiple

User-owned and organization-owned entities

RetrievePrincipalAccess

User-owned entities only

RetrieveSharedPrincipalsAndAccess

User-owned entities only

RevokeAccess

User-owned entities only

SetState

User-owned and organization-owned entities

SetStateDynamicEntity

User-owned and organization-owned entities

Update

User-owned and organization-owned entities

Leave a Reply