Overview of Plugins

What is a Plugin?

A plug-in is custom business logic (code) that you can integrate with Microsoft Dynamics CRM Online or OnPremise to modify or augment the standard behavior of the platform.

Event execution pipeline

The Microsoft Dynamics CRM event processing subsystem executes plug-ins based on a message pipeline execution model. A user action in the Microsoft Dynamics CRM Web application or an SDK method call by a plug-in or other application results in a message being sent to the organization Web service. The message contains business entity information and core operation information. The message is passed through the event execution pipeline where it can be read or modified by the platform core operation and any registered plug-ins.

Note: While there are several Web services hosted by the Microsoft Dynamics CRM platform, only events triggered by the organization and OData endpoints can cause plug-ins to execute.

Architecture and related components

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

Plugin Architecture

Points to Remember:

  1. The event execution pipeline processes events either synchronously or asynchronously.
  2. The platform core operation and any plug-ins registered for synchronous execution are executed immediately.
  3. Synchronous plug-ins that are registered for the event are executed in a well-defined order.
  4. Plug-ins registered for asynchronous execution are queued by the Asynchronous Queue Agent and executed at a later time by the asynchronous service.
  5. Regardless of whether a plug-in executes synchronously or asynchronously, there is a 2 minute time limit imposed on the execution of a (message) request. If the execution of your plug-in logic exceeds the time limit, a System.TimeoutException is thrown. If a plug-in needs more processing time than the 2 minute time limit, consider using a workflow or other background process to accomplish the intended task.

Pipeline Stages:

Event Pipeline Stages are 4, in which we can register plugin in 3 Stages.
Stages

Images

Pre Image: A pre-image is a snapshot of the entity’s attributes before the core operation.

Availability of Pre Images for the Plugin stages,

Pre Image

Post Image: A post-image is a snapshot of the entity’s attribute after the core operation.

Availability of Post Images for the Plugin stages,

Post Image