30 June 2013

Orchard CRM - The Application Design.

The design is simple: Use Orchard as the host system to manage user access, web site content etc.
and then adding a custom module to integrate with Dynamics CRM.
This approach can be used in many scenarios where you want to integrate the existing portal website and a back-end system. In this case, the back-end system is Dynamics CRM, and the front-end system is Orchard CMS.

Mapping is the key

You can mapping an portal user to many CRM records types if you like, i.e. Account, Contact, User, Team etc. Most commonly, as we are doing here, mapping to a Contact record in Dynamics CRM. Like other systems, an authorised Orchard user has an unique and read-only ID, which will be used to identify if this user is in CRM or not. In my sample code, the Orchard identifier is: _orchardServices.WorkContext.CurrentUser.Id.
The mapping field in CRM is ‘externaluseridentifier’ which is a system attribute in the Contact entity (the only reason I choose this field is because it's out of box, good for the demo purpose). You can also use your custom identifier to mapping a Orchard user and CRM contact record, but make sure this field and value shouldn't be modified by CRM users.

The following diagram shows the overall structure of how it works.
Orchard CRM - How It Works

MVC is the core

The custom module calls DynamicsCRM in my sample code, it's an undecorated MVC application (99%) with some Orchard-specific features (1%). I say it's undecorated, because you don't need to write any CSS code etc. The custom module can inherit look&feel from the host theme by simply declaring an Orchard class [Themed] in the controller.

The advantage is obvious: First of all, you can focus on the core-functionality development and leave the rest of work to Orchard. Secondly, the core MVC code can be reused elsewhere, i.e. you can use it to develop a portal app for SharePoint public facing website etc.


The following diagram shows the MVC core function in the DynamicsCRM module.
DynamicsCRM module - MVC Core
The rest files are mostly Orchard specific and really easy to understand.

Here's some links for this solution:
DynamcisCRM module (with sourcecode) for Orchard CMS
Orchard CRM portal demo
Previous articles about Orchard CRM:
Microsoft Dynamics CRM and CRM Portal website
Orchard CRM - A concept of Dynamics CRM Portal Solution


Cheers,
Jim Wang
June 2013