RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Extending Microsoft Dynamics CRM 4.0 with Plug-Ins

Microsoft Dynamics CRM 4.0 has a very flexible infrastructure that lets you extend the out-of-the-box behavior to meet ever-changing organizational business needs.


hile the default behavior of Microsoft Dynamics CRM 4.0 is completely functional, it's also general; more often than not, you'll find you need to augment it based on specific business demands. Microsoft Dynamics CRM 3.0 supported custom business logic in the form of callouts and workflows, but Microsoft Dynamics CRM 4.0 adds even more robust support for custom business logic in the form of plug-ins. Workflows in Microsoft Dynamics CRM 4.0 are now based on Windows Workflow Foundation 3.0 which increases their power to extend MS CRM's behavior.

Author's Note: Microsoft Dynamics CRM 4.0 online does not support plug-ins; however, it does support workflows.

In this first part of a two-part article you will see how to capitalize on the unified event framework for plug-ins to expose entity events to a broker service, which publishes these events, and to notify clients subscribing to these events. A good integration scenario would be to publish CRM entity audit information to a SharePoint list which can then be showcased to a variety of audiences. The broker service is a topic-based publisher/subscriber (pub-sub). A pub-sub-based architecture allows any subscriber bound to the contract to access CRM audit information.

You can find more information on topic-based publish-subscribe operations here

What You Need
  • Basic understanding of Microsoft Dynamics CRM 4.0
  • Some familiarity with .NET Framework 3.0 concepts, such as Windows Communication Foundation (WCF)
  • Some knowledge of Windows SharePoint Services 3.0

The Unified Event Framework API

Microsoft Dynamics CRM 3.0 offered separate interfaces for extending the custom behavior using callouts and workflows. In contrast, Microsoft Dynamics CRM 4.0 has a unified event framework for both plug-ins and workflows, which reduces the overhead of using separate interfaces and makes the model very flexible.

Here are the key features of the unified event framework:

  1. Custom extensions (plug-ins/workflows) are portable because they use the same runtime.
  2. Workflow activities and plug-ins are deployed to the database, thereby making the distribution very easy.
  3. Both asynchronous and synchronous processing are supported. Plug-ins registered for synchronous processing execute immediately, whereas plug-ins registered for asynchronous processing are queued.

Pre and Post Events

Figure 1. : Event Execution Pipeline. CRM messages flow through the system as shown in the diagram.

A call to a CRM service is treated as a message. The unified event framework exposes a five-stage event pipeline that processes the message in a synchronous or asynchronous fashion.

Figure 1 shows the path of a CRM message through different stages of the pipeline.

Custom plug-ins are allowed at only two stages of the event pipeline:

  1. At the pre-event stage, before the core operations execute and database transactions begin.
  2. At the post-event stage—after the core operations complete.
Author's Note: For multiple plug-ins the order of execution is determined during the registration process.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date