An Introduction to XRM for a .NET Developer (Microsoft Dynamics CRM 4.0)
Shan McArthur, ADXSTUDIO, Inc.
Shan McArthur from ADXSTUDIO, Inc. writes about XRM.
Microsoft Dynamics CRM 4.0
The purpose of this article is to give an introduction to XRM for .NET Developers and application architects. Most developers are familiar with various Microsoft technologies including the .NET Framework, Microsoft SQL Server, WPF, and ASP.NET. They are accustomed to designing their applications using Microsoft SQL Server for data storage and modeling their applications using relational database techniques. Modern developers are also familiar with object-to-relational mapping frameworks including Entity Framework and LINQ-to-SQL. Developers who like to live on the bleeding edge are also familiar with AJAX, Silverlight, ADO.NET Data Services, and .NET RIA Services. This article will introduce using Microsoft Dynamics CRM for the data storage tier of an application, paralleling it to basic concepts that are used in designing applications using SQL Server.
What is XRM?
There are a couple of different definitions for XRM. One is that the “x” stands for extended, as in extended relationship management. The other definition is that the “x” is a variable, and means “anything” relationship management, such as partner relationship management, constituent relationship management, employee relationship management, etc. Both of these definitions are referring to building any application on top of the Microsoft Dynamics CRM platform. Building an XRM application can take the form of customizing the existing customer relationship management applications that are included in Microsoft Dynamics CRM, or by designing completely new line-of-business applications that are not based on the sales, service, or marketing capabilities included in Microsoft Dynamics CRM. The common thread to all the definitions of XRM and methods of extending it is that your application will use the Microsoft Dynamics CRM as a platform, leveraging the capabilities of the platform to deliver business value to your users.
There are a number of advantages to building an application on top of Microsoft Dynamics CRM instead of SQL Server. The most obvious advantage is that the Microsoft Dynamics CRM platform comes with a number of in-the-box entities and applications that are immediately usable. For example, Microsoft Dynamics CRM includes helpdesk (or case management), service scheduling, activity tracking, e-commerce, marketing campaigns, and sales-force-automation. These applications may or may not be a part of your XRM application design. Even if you don’t use these applications or Microsoft Dynamics CRM entities, there are a number of other features that the Microsoft Dynamics CRM can deliver for your custom XRM application. Microsoft Dynamics CRM includes the following features for any XRM application:
Security. Microsoft Dynamics CRM has a strong security model baked into the platform. This includes a concept of ownership and sharing of records (record-level security), roles, business units, and a permission model that includes the concept of scope (that is, editing records owned by me, within my business unit, or throughout the entire organization).
Workflow. Microsoft Dynamics CRM has a workflow model including an end-user interface that allows business users to manage workflows on any entity in Microsoft Dynamics CRM. This workflow model includes conditions, branching, and custom actions, including sending e-mails or creating additional Microsoft Dynamics CRM records. These workflows can be implemented by individual users to enable them to automate some of their own personal workflows or can be set to run across the entire organization to implement particular business logic or behaviors. The workflow engine can also be extended by developers, exposing custom workflow actions in the workflow designer.
Reporting. Microsoft Dynamics CRM uses both Microsoft Office Excel and Reporting Services for reporting. It includes a reporting wizard that walks the user through creating useful reports on data stored in Microsoft Dynamics CRM. These reports can be relatively static, or even dynamic with drill-down capabilities. These reports are then available to be shared with other users in Microsoft Dynamics CRM.
User Interface. When you customize Microsoft Dynamics CRM with your own custom entities for your XRM application, the Microsoft Dynamics CRM system will automatically generate a GUI for your users to interact with the data. Microsoft Dynamics CRM includes a primary console interface that can be customized for your XRM application. The user interfaces include lists with customizable views, find and advanced find, editors for all entities, lookup dialogs, multi-tabbed user interfaces, and more. Microsoft Dynamics CRM delivers these user interfaces with no programming required. User interfaces for related records are automatically generated simply by adding relationships between different entities. The user interfaces include all standard mechanisms for manipulating the data including full create/edit/delete operations, ownership assignment, and running of workflows. The user interfaces even allow for batch editing of records.
Office Integration. Microsoft Dynamics CRM has a strong integration story for Microsoft Office. It includes an online and offline client that can be installed on a workstation. This brings the Microsoft Dynamics CRM user interface into Microsoft Office Outlook where users can interact with the Microsoft Dynamics CRM system directly within Outlook. The offline client allows for users to disconnect with the office network and still interact with Microsoft Dynamics CRM data while on the road, synching back up with Microsoft Dynamics CRM when they return to the office. The Microsoft Dynamics CRM client also enables data to be pulled directly into Microsoft Office Word and Microsoft Office Excel using active data binding. All data in Microsoft Dynamics CRM can easily be imported and exported with Excel.
Data modeling. Microsoft Dynamics CRM allows for the creation of custom entities, which can have attributes, forms and views, and relationships with other entities. In addition to standard relationships, all custom entities can have activities and notes if desired. Activities allow for collaboration using standard Microsoft Dynamics CRM activity records such as tasks, e-mail, phone calls, appointments, and service scheduling. Notes allow for file uploads and other comments to be associated to custom entities.
Web Services. Microsoft Dynamics CRM includes a number of Web services that can be used to interact with the Microsoft Dynamics CRM platform. These services are SOAP Web services and allow for open extensibility and use across any platform using any language that supports Web standards. It is also possible to use third-party tools such as ADXSTUDIO XRM SDK to implement modern data services such as RESTful services based on ADO.NET Data Services and .NET RIA Services with very little coding. This allows Microsoft Dynamics CRM data to be easily consumed in XRM Web applications using AJAX or Silverlight development.
The Microsoft Dynamics CRM application is implemented on top of SQL Server and you will find that the Microsoft Dynamics CRM data model parallels typical SQL Server data models quite closely. In SQL Server, to create a custom business object, you would create a custom table, and within that table, you would define columns for all of the attributes of that object. For example, for an asset, you would create an “asset” table, and create columns for the primary key, the asset name, purchase price, and so on. You would also likely have a table in SQL Server to store your users, and then add a column to the asset table called “custodian” that would be a foreign key to the user table to represent a many-to-one relationship between the asset and user tables. Microsoft Dynamics CRM data modeling is very similar, so your existing SQL Server design skills will transfer very quickly to Microsoft Dynamics CRM. Using the same business model, you would create a custom entity called “Asset” in Microsoft Dynamics CRM. When you create this entity, you would automatically get a name field, and a primary key field. You would also specify the plural name of the entity (“Assets”), which will be used to automatically generate many of the labels in the user interface. Microsoft Dynamics CRM already has a “User” entity, so you would not need to create that business object. You would then add attributes to the asset entity to store the purchase price, and other attributes that you want to track for the asset. To add the many-to-one relationship between “Asset” and “Users”, you would simply go to the many-to-one relationship tab and add a new relationship between the two entities. As you can see, data modeling in Microsoft Dynamics CRM is very similar to data modeling in SQL Server.
Figure 1 - Creating New Asset Entity
Figure 2 - Attributes View on Asset Entity
I have designed the asset management sample in SQL Server and Microsoft Dynamics CRM. Here are the design diagrams for the same data model in both platforms:
Figure 3 - SQL Server Database Diagram
Figure 4 - XRM Class Diagram
Productivity and Collaboration in Design
We have demonstrated that data modeling in Microsoft Dynamics CRM is very similar to data modeling in SQL Server. The effort required for both is about the same. If that were the only case, designing for Microsoft Dynamics CRM and for SQL Server would be on equal footing. Fortunately, Microsoft Dynamics CRM has a number of advantages that significantly improve the application design experience and reduces the overall effort required to complete real-world applications.
Once the basic entities and relationships are modeled, it is only a click away to the forms and view designers. Microsoft Dynamics CRM has a number of defined views for each entity, including active and inactive views, associated views, and lookup views. There are even views that define which columns are to be used for free-text searches. For each of these views, Microsoft Dynamics CRM gives you a user interface that enables you to see the column sizes, order of columns, and default sorting options. You can easily reorder the columns, and add or remove columns from the views. You can even add columns from other entities that are joined to the entity though a many-to-one relationship. Defining the views for an entity requires only a couple of minutes.
Figure 5 - All Forms and Views for Asset Entity
Figure 6 - Customizing View for Asset
In addition to views, Microsoft Dynamics CRM has a customizable form for each entity. This form is used for the edit interface for the entity. It has multiple tabs and sections. You simply add your tabs and sections, and then add fields to those sections. There are many layout options, with a two-column design being the default design. You can simply double-click on a field and change many of the field behaviors, design parameters, and labels. You can move the fields around easily on the design surface by simply clicking the directional arrows in the task panel. Again, it only takes a few minutes to design a reasonable form for a custom entity.
Figure 7 - Form Designer for Asset Entity
Once you publish these changes to Microsoft Dynamics CRM, you can immediately start to enter data in Microsoft Dynamics CRM for your application. The entities will be located in the wonderbar sections that you have specified and when you click on the entity name, you will have a list view that allows you to browse your records, add new records, edit existing records, and even delete records. When you either add a new record or edit an existing record, Microsoft Dynamics CRM will present you with a popup screen using the form that you have designed.
Figure 8 - Main Microsoft Dynamics CRM Window Focused on Assets
Figure 9 - Data Entry Form for New Asset
Simply use the interface to specify your data. For any many-to-one relationships, Microsoft Dynamics CRM will give you an auto-complete field and a lookup button that will assist you in locating existing or creating new records of entities that are appropriate for that field. The lookup button will open a new window and allow you to quickly locate a record to use for the field. The Microsoft Dynamics CRM user interfaces are very easy to use and enable users to enter data in a very short period of time. Compared to SQL Server, you either would have to write a data entry application or directly insert the rows in the database, which is not nearly as efficient or as easy to use as the Microsoft Dynamics CRM user interfaces.
Figure 10 - Lookup Screen to Select Custodian of Asset
For one-to-many or many-to-many relationships, Microsoft Dynamics CRM has tabs down the left side of the editor for each of the relationships, and when you select these tabs, a list view of related records is displayed on the right. You can associate existing records, or even create new records using this user interface.
Figure 11 - Using the Section Tabs on the User Entity to View Assigned Assets
Note that no development effort has been required yet. It is typical to do Microsoft Dynamics CRM data modeling directly with the end user. It is also typical to skip an entire documentation phase in the design stage and model the application directly with the end user. There are a number of benefits to this approach. The user interfaces are very intuitive and easy to understand. End users can provide data requirements directly while the Microsoft Dynamics CRM designer is creating the entities and attributes. End users are very invested in having a productive user interface and typically have a lot of expectations on how the forms are designed. It is simple to design the form directly in the interview with the user. Once the forms and views are designed, it is easy to start adding sample data. This has a number of important benefits. Sample data will let the user see how the user interfaces will operate, and it will confirm that your data model has been set up properly. At the end of the design meeting with the user, they will be left with a Microsoft Dynamics CRM application that they can explore and validate that it meets all of their requirements. End users have a difficult time digesting large design documents and it is easy to miss things in a design document because it is not a live system. Validating a design using a live application allows for much better feedback, reducing the errors and costs of making modifications later in the development cycle. This approach significantly minimizes the documentation required in the design stage of an application, reducing the costs of the development of the application.
Business Processes and Workflow
Real applications are much more than a simple data model. Most organizations have complex business processes that need to be modeled and implemented in the application. In a SQL Server application, this would require that the developer collect all the business rules and processes and implement that in the application that they are developing. An XRM application will leverage the Microsoft Dynamics CRM workflow engine to enable the end users to define organization-wide or even personal workflows to implement these business rules and processes. Since users can adjust these workflows at any time, it makes an XRM application easier to support in an organization as the business changes. Consider that end users have access to the workflow design interfaces and can make adjustments themselves without going through a development cycle that would require IT involvement.
The Microsoft Dynamics CRM workflow engine is very complex, and it has a broad set of capabilities. For example, it has logic operations that can be used to implement branching logic, it can be triggered by create/update/delete operations on data or manually by the end user, and it can update Microsoft Dynamics CRM records or even perform actions like sending an e-mail. It is also extensible by developers.
For our asset management application, let us say that the office manager wants to receive an e-mail whenever a new asset is added to the system. This would be accomplished by creating a workflow on the Asset entity.
Figure 12 - Creating a new Workflow on the Asset Entity
Once you create the workflow, you need to specify how it will be triggered and the workflow steps to take. The workflow steps can contain branching logic and wait conditions. The actions can include creating new or updating existing records, changing the status or record ownership/assignment, sending e-mail, or even starting a child workflow. In this scenario, we wanted to send an e-mail, so we will add a step to send a new e-mail to the workflow.
Figure 13 - Defining the Workflow
When sending an e-mail, it is often important to customize the e-mail with some of the data relevant to the entity that the workflow is operating on. The Microsoft Dynamics CRM workflow e-mail designer allows you to insert slugs for dynamic properties that will be used when the workflow is running. These show up highlighted in yellow.
Figure 14 - Customizing the Workflow Email
You can see that Microsoft Dynamics CRM offers many excellent capabilities that are suitable for many types of applications. Building an XRM application is a highly collaborative process that involves both IT and business users working closely together on a real system.
XRM supports a very agile application development process. The most important thing to consider is that the user will be working with a functional application, and because of that, will be able to provide a very high quality of feedback early in the design stage. Business rules are implemented in workflows and are very easy to adjust when business requirements are changing, and these adjustments can typically be made with little or no involvement from IT.
The process of building an XRM application on Microsoft Dynamics CRM is really no different than building the same application directly on SQL Server. The main difference is that it requires significantly less effort to complete a full application as the native capabilities of workflow, reporting, user interfaces, security, Web services, and Office integration in Microsoft Dynamics CRM can be leveraged instead of building it from scratch for each application.
For more information about Microsoft Dynamics CRM, visit the Microsoft Dynamics CRM Developer Center on MSDN.
About the Author
As vice president of technology at ADXStudio Inc., Shan McArthur is responsible for establishing the technical and infrastructure strategies and standards. He is the senior architect and product manager for their flagship product - ADXSTUDIO CMS. The product is a .NET Web content management system (WCMS) that is fully integrated with Microsoft technologies including Microsoft Dynamics CRM.