Microsoft Typescript

In the last few years Javascript has largely taken over the world, ever since we first laid eyes on Google Suggest and Outlook Web Access to see what could be possible using Javascript (and later AJAX) to make Web Applications as fluid and dynamic as desktop applications, Javascript has been a growing technology. (debatably outstripping it’s parent language Java which it now has little in common with)

The counterbalance to this is that Javascript brings all the bad old ways of any other scripting language – no intellisence, no compilation, difficult to use namespaces and well managed names, fairly poor error handling and a worrying tendency to code bloat.  These problems can be avoided through good development standards and carefully usage, but the language naturally leans into some difficult to manage areas for the average developer.

(how many Dynamics CRM projects have we seen with several hundred lines of Javascript stuffed into the onLoad event – it’s better in CRM 2011 with the proper use of includes Web Resources but can still be a problem)

Despite all these points – Javascript is used the world over because it works in all browsers and adds the vital scripting logic to support basic HTML.

Today however Microsoft have released a simple framework that acts to allow developers to build Javascript in Visual Studio in a more manageable C# Development format that then ‘compiles’ into native Javascript.

http://www.zdnet.com/microsoft-takes-the-wraps-off-typescript-a-superset-of-javascript-7000004993/

This is aimed at providing developers a more structured approach to writing Javascript – in a way this is slightly off-topic for CRM 2011 Consultancy and Development, but as a long-time fan of making sure all your CRM Javascript (whether in CRM 4 files, or CRM 2011 Web Resources) is developed in Visual Studio and stored in a source-controlled Project, is also in a way very on-topic for CRM 2011 development.

TypeScript Hello World

When learning anything new in the development world, it tends to help by stripping all the complexity or ambiguity away by producing the most basic usage imaginable – the hello world example.

First of all – you can download the Visual Studio 2012 extension for Microsoft TypeScript at the following link: http://www.microsoft.com/en-us/download/details.aspx?id=34790

This installs a new Project Type into Visual Studio:

Creating a new TypeScript Project in Visual Studio 2012

Creating a new TypeScript Project brings up a Visual Studio Project containing  the following files:

App.ts – the pre-compiled source file for the TypeScript, this our code for developing the program code which will be compiled into Javascript.

App.js – the raw Javascript which the TypeScript compiler produces from the App.ts

Default.htm – the HTML file which includes the ‘app.js’ as a normal Javascript include.

We can then edit our ‘App.ts’ code file using a more familiar C# syntax as way of writing the code at a higher level of abstraction to the underlying Javascript.

As way of an example, we could create the following simple object:

class MyClass {
    _activatedString: string = "(( hello world ))";
    _deactivatedString: string = ")) goodbye world ((";

    _myHTMLElement: HTMLElement;
    _stateElement: HTMLElement;

    constructor (outputElement: HTMLElement, stateElement: HTMLElement) {
        this._myHTMLElement = outputElement;
        this._stateElement = stateElement;        

        this.deactivate();
    }

    public click() {
        if (this.getActive() == false) {
            this.activate();
        }
        else {
            this.deactivate();
        }
    }

    private getActive(): bool
    {   
        if (this._stateElement.attributes["value"] == "true") {
            return true;
        }
        else {
            return false;
        }
    }

    private setActive(value: bool)
    {
        if (value == true) {
            this._stateElement.attributes["value"] = "true";
        }
        else {
            this._stateElement.attributes["value"] = "false";
        }
    }

    private activate() {
        this._myHTMLElement.innerText = this._activatedString;
        this.setActive(true);
    }

    private deactivate() {
        this._myHTMLElement.innerText = this._deactivatedString;
        this.setActive(false);
    }
}

NOTE: Proof of the TypeScript approach might be in whether WordPress’s CSharp engine is better than the Javascript engine for showing the source code here.

This gives us a simple object that encapsulates two HTML Elements, uses one as the object’s output and the other as a hidden element for storing the object’s viewstate. 

This compiles from the TypeScript to the following raw Javascript:

var MyClass = (function () {
    function MyClass(outputElement, stateElement) {
        this._activatedString = "(( hello world ))";
        this._deactivatedString = ")) goodbye world ((";
        this._myHTMLElement = outputElement;
        this._stateElement = stateElement;
        this.deactivate();
    }
    MyClass.prototype.click = function () {
        if(this.getActive() == false) {
            this.activate();
        } else {
            this.deactivate();
        }
    };
    MyClass.prototype.getActive = function () {
        if(this._stateElement.attributes["value"] == "true") {
            return true;
        } else {
            return false;
        }
    };
    MyClass.prototype.setActive = function (value) {
        if(value == true) {
            this._stateElement.attributes["value"] = "true";
        } else {
            this._stateElement.attributes["value"] = "false";
        }
    };
    MyClass.prototype.activate = function () {
        this._myHTMLElement.innerText = this._activatedString;
        this.setActive(true);
    };
    MyClass.prototype.deactivate = function () {
        this._myHTMLElement.innerText = this._deactivatedString;
        this.setActive(false);
    };
    return MyClass;
})();

In affect this is simply a clever use of the Javascript Prototype pattern which I’ve seen used for CRM 2011 Projects – but you can clearly see the similarities between the .ts and the .js, but the TypeScript here does seem to produce more human readable code and gives a set of syntax that is much in common with C#.

We also can leverage strongly typed fields such as string, number and HTML Element as opposed to Javascript’s var and object.

The big advantage to both OO Javascript and the TypeScript here is to instance the object as a single black-box unit of code, and potentially instance multiple times – so if we look at the HTML which will invoke this Javascript:

<body>
    <h1>TypeScript HTML App.</h1>
   
    <input id="t1_button" type="button" value="Click Me" />
    <input id="t1_state" type="hidden" value="false" />
    <div id="t1_content"></div>

    <input id="t2_button" type="button" value="Click Me" />
    <input id="t2_state" type="hidden" value="false" />
    <div id="t2_content"></div>    
</body>

We can see two sets of HTML controls which our script will use as (mostly) encapsulated objects:

window.onload = () => {
    // declare 1st instance of the class
    var myClass = new MyClass(document.getElementById('t1_content'), document.getElementById('t1_state'));
    document.getElementById('t1_button').onclick = () => myClass.click();

    // declare 2nd instance of the class
    var myClass2 = new MyClass(document.getElementById('t2_content'), document.getElementById('t2_state'));
    document.getElementById('t2_button').onclick = () => myClass2.click();
};

This gives us 2 simple controls each with their own viewstate:

The Resulting HTML Webpage using the Javascript compiled by the TypeScript – showing two controls with their own javascript managed viewstates.

And when working in the TypeScript Visual Studio environment – a good level of intellisense for using the classes we define:

Using the TypeScript Intellisense in Visual Studio 2012 for the MyClass type

So far, so normal web development, but this could provide a useful way of developing and producing (or at least managing) CRM Javascript and certainly could be a help for HTML Webresources.

Depending on how useful TypeScript proves to be for CRM Form Scripting and how much of the Object Orientated Intellisence model we can leverage, this could be a topic to keep in mind for CRM Development.

Handy TypeScript Links

I imagine this will expand depending on how popular TypeScript becomes, but the following links come from more experienced JavaScript developers looking into TypeScript from a similar Hello World perspective:

http://www.devcurry.com/2012/10/hello-typescript-getting-started.html

http://www.amazedsaint.com/2012/10/microsoft-typescript-and-quick.html

http://blog.markrendle.net/2012/10/02/the-obligatory-typescript-reaction-post/

Posted in Consultancy, Development, JavaScript, Technical | Tagged , , | Leave a comment

The Customer in CRM – Going Social?

In between the technical concerns of deploying a CRM System such as Dynamics CRM there is always the wider more important strategy of how a company incorporates a CRM Solution (of which the system is but a part of) into their business – and this strategy obviously has aims or expected benefits that come from the changes involved.

Often these aims have looked inward to a business and as a result focused on the Business User Experience of a CRM Solution, however a strongly implemented CRM Solution should also focus on the other key part of a business, the Customer.

This post aims to look at how the Customer may have changed in the recent past and how this may affect the Analysis and Design of a CRM Solution in terms of examining the Customer Experience hand-in-hand with the User Experience.

The rise of a social product

Often in today’s culture customers have a concept of not simply buying a ticket or going to an event – but buying into the event, the social nature of whatever that event is.  This may sound superfluous – but if we look at how the world has changed with the advent of the network providing instant easy access to almost everyone:

– How many people go to the cinema to watch a film and then check out other people’s thoughts and comments on the film the next day? Not just limited to traditional reviews of the film, but comments on people’s reactions to the film – often mostly from their social circle of online friends but also from other random sources.

– How many people now regularly post what gigs or festivals they are attending, and then use replies or apps to then guide what they will do when they are there.

– Not to mention the number of people who will update their Status to register that a particular product or purchase has arrived, or to detail a particularly good (or bad!) experience they have had with a brand or company.

Essentially people (or customers) have always done this and discussed events or products with their friends or family, giving rise to the power of word of mouth marketing and the ability for customers to trust products or suppliers based on this word of mouth.

Going Social is a bit of a myth, people have always been social and naturally enough taken that into how they buy products and services.

However the advent of social media has given us all new channels to communicate this word of mouth, and in a way define ourselves via certain experiences, products and brands that we associate with.

Often when I have read about these applications of Social Media in the past I have been quite sceptical about whether people actually engage or want to engage on these points – however I think the rise of Web 2.0 (which is now almost old-hat, but I guess that is the point in a way!) with the mainstream adoption of Facebook, Twitter and Mobile Apps have changed people’s perceptions on these points.

Having worked in ‘old-style’ Sales and Event environments where our promotion of products was largely limited to traditional outlets (face-to-face, leaflets and so on) – it has become increasingly common for customers to expect and want more active social promotion than I have seen in the past; I found customers wanting an event to be something that is worth buying into, and so something that already has that social presence that they can spread to their friends/followers as a way of identifying themselves.

In a way this is how we might define the outcome of the Customer Experience that the customer has with our service or product, essentially the result of the relationship between us as the supplier and the customer.  This relationship being at the heart of CRM as a strategy for our business.

Where is the Customer in CRM?

What this aims to describe is the ‘Customer Experience’ or how the Customer relates to a particular Product or Service which should in theory be at the heart of what Customer Relationship Management is all about – the understanding and possible facilitation in how Customers relate to a Product or Service.

However if we look at many of our CRM Projects today, how many of them look into the idea of how the Customer looks at the business’s product? Often CRM Projects largely focus on automating or assisting a business’s internal processes – sometimes the goal being simply to improve existing processes via more sophisticated technology.

(how many times have we seen the requirement to replace X, Y. Z legacy system to avoid £30,000 support costs a year say; or to produce a all-singing all-dancing system that integrates better to reduce data re-entry?)

There is obviously nothing wrong with these projects, saving money and being more efficient as a business is a good aim – however are these really CRM-focused projects, is the customer at the heart of these projects or simply a concept described through the more important needs of the business.

In a way these are more Business Process Improvement projects that happen to use a CRM Application to achieve their results – you might use Dynamics CRM to give the Sales Team a standardised process that then feeds Order information to the back-end ERP system to allow Invoice statuses to be visible to the front-office as well as the back-office, but where is the customer in that project brief?

Am not sure that defining terms such as ‘what is real CRM’ is particularly helpful – however the following points may be useful when asking the question ‘where do your customers fit into this project?’ as opposed to CRM being purely focused on the requirements of the business rather than the requirements of the customers:

– When does the Customer interact with this business process

– Is the Customer interacted with (you to them), or do you expect the customer to interact with you? (them to you)

– What channels do you use or expect the Customer to interact with you throughout the process.

– Does the Customer know where they are with you at different stages in the process?  And if so, how?

There is a lot of fluff and hype around social media and terms like Customer Experience which can sometimes be unhelpful in understanding how a business might actually benefit and ultimately make money from these sometimes abstract concepts – however as CRM Consultants running workshops with different businesses, I think it is useful to think along these lines and frame questions away from ‘what are your requirements for a CRM Solution’ and more ‘what are the requirements that your customer has of you’ and then for us to provide the solution that delivers these customer-focused requirements.  In a way this dove-tails with the common (and crucial) concept of providing a User Experience for a new CRM System, but in a way that provides a Customer Experience as part of how a CRM Solution fits into the business.

Obviously the customers may never see or interact with the actual CRM System, but their experience of the business is obviously a crucial part of the CRM Solution that the system is a part of.

Does this Customer Experience really matter?

Whilst the idea of managing a customer experience towards building a better relationship is a good natural idea for a business – does this idea actually translate into higher sales in a real-world sense, and if so how can we actually ‘prove’ this to validate the idea.  Marketing Departments everywhere know the problem of convincing budget-holders that their efforts produce tangible sales from the back of brand promotion and other indirect channels.

In a sense more modern technologies allow us to roughly measure the benefits of the relationship that a customer has to us as the business – Twitter/Facebook hashtags, followers and other factors give us more tangible metrics that can be captured within a CRM Solution to give us a feel for the strength and productivity of a relationship.

To give a practical feel for this, I imagine a baseline of factors to capture might be the following:

– Relationship Strength, to describe how we perceive the customer relates to our business.

– Influence Rating, to describe the customer’s likely ability to influence other customers within the market.

– Network Rating, how well networked is a particular customer.  This can overlap with a customer’s level of influence but is essentially a different attribute given that a customer can be well-networked but not a strong influencer.

– Purchase Strength, how much purchasing power does the customer bring to our business – this factor may (and should) be known by CRM itself as opposed to external connections to Social Media but can then be compared against the strength of the Relationship and level of Influence.

These factors are not new and have been previously captured within CRM Solutions, but the rise of Social Media allows us a more direct method of collecting this data – even to automatically harvesting the number of mentions or updates concerning our business or product directly from Twitter or other media via CRM integrated with the media’s API.

The strength here being the ability for CRM Solutions to crawl Social Media alongside the usual manual factors and automatically give a score to a customer as way of identifying key customers that act as advocates or influencers for your brand.

Conclusion

Obviously many of these concepts are not new and have been discussed at some length with the now wide-spread use of Facebook, Twitter and others; but I believe these ideas have come of age now to the point where these are practical concerns for many businesses and deserve incorporation into our thoughts and designs for CRM Solutions – particularly in the Business-to-Consumer market which is increasingly cut-throat with the recessionary climate we find ourselves in, and the ability to build a strong brand that customers want to be a part of provides a powerful tool in resisting recessionary pressures.

Am always minded to remember that many businesses across the world are run (and sometimes very successfully) on a mish-mash of Excel Spreadsheets a million miles removed from these concepts, and often our initial brief as CRM Consultants and Project Managers is to simply consolidate these into a CRM Database, but I think that these concepts should increasingly find a place in the wider CRM Strategy we should be advising for a business.

Am a huge advocate of properly thinking through the User Experience for the Analysis and Design of CRM Solutions as I have seen many specifications which concentrate purely on the technical implications of a design without reference to the end-user, and I think defining the Customer Experience of the CRM Solution is now becoming just as important to creating a successful project.

And above all after a weighty 1500 words or so – Happy 2012 to everyone reading this!  After a heady wait since 2005, the Olympics are coming to my corner of the world very soon now!

References / Interesting Reading

There is many great references on how Social Media interacts with CRM, the following is a small list that I have found a good read on the topic without losing sight of the day-to-day reality of business:

How should firms adapt to serve the channel agnostic customer? – MyCustomer.Com

http://www.mycustomer.com/topic/customer-intelligence/how-should-firms-restructure-channel-agnostic-customer/126641

CRM 2012 Forecast – The Era of Customer Engagement – Paul Greenberg, ZDNet

http://www.zdnet.com/blog/crm/crm-2012-forecast-the-era-of-customer-engagement-part-i/3753?tag=search-results-rivers;item0

Posted in Consultancy, Project Management, Social CRM | Tagged , , , | 2 Comments

Integrating Dynamics CRM Data into SharePoint 2010

Years ago I worked on a development team looking at the requirements of a good CRM System that could be developed to fit various business models, and one of the key requirements we determined was the ability to pull data from other sources around a business into the solution as a way of integrating business data (possibly as external entities) into the core business CRM Solution.

Sounds simple in theory but can be pretty tricky in practise.

When SharePoint 2007 came on the scene a few years ago, the Business Data Catalogue looked an ideal solution to this requirement – able to define and pull certain areas of data from external Datasources by defining them as Business Data Entities.  However despite the BDC being sold as a ‘no-code’ tool for integrating this data into SharePoint, it did involve specifying your Data Areas via a bespoke XML file – and to me documenting the schema of your data via XML felt pretty much like writing code, and not easy to implement. (honourable mention to Lightning Tools which made this process easier with a workable front-end)

With SharePoint 2010 I thought it was about time to take another look at this topic as the Business Data Catalogue has regenerated into the Business Connectivity Service and now comes alongside SharePoint Designer to allow for easier actual ‘no-code’ solutions to this age-old problem of integrating external sources of data into a single Line of Business Solution.

To look at how this can be implemented in SharePoint and coming from a Dynamics CRM angle, this post will be focused on how we can integrate CRM 2011 data into SharePoint 2010.

To make this post more readable given the technical complexity of SharePoint, the article is broken down into the following sections:

1. SharePoint Designer
2. Defining an External Content Type
3. Using the External Data within other SharePoint Lists
4. Adding Custom Actions
5. Conclusion and References

1. SharePoint Designer

SharePoint Designer is a fantastic little desktop application which connects to a SharePoint site to increase the speed and ease in which standard customisations can be added to the site.

Microsoft first tried this approach by adding functionality to FrontPage (TODO: Link) to connect to SharePoint 2003 sites with mixed results, and I often found it easier to simply perform the customisations using SharePoint’s native Web Interface – however in my experience SharePoint Designer is leaps and bounds ahead of these early efforts and makes adding and customising Custom Lists and other aspects of SharePoint sites considerably easier and quicker than the native Web Interface.

image

The SharePoint Designer home-page

This post will refer heavily to the SharePoint designer (alongside the Web Interface in places) for making the necessary changes to a SharePoint Site to facilitate the integration with CRM Data.

The SharePoint Designer is freely available can be downloaded via the following links:

Download SharePoint Designer (64-bit) http://www.microsoft.com/download/en/details.aspx?id=24309

Download SharePoint Designer (32-bit)http://www.microsoft.com/download/en/details.aspx?id=16573

2. Defining an External Content Type

First of all we need to activate External Content Types within our deployment of SharePoint via the Central Administration area by ensuring that Business Data Connectivity Service is running.

This will allow us to view and amend the list of External Content Types within SharePoint Designer:

image

Showing the list of External Content Types in a SharePoint Deployment via the SharePoint Designer

From here we can add a new External Content Type that acts as a wrapper to show CRM Data within SharePoint.

This is done via the following steps:

(1) Add a new External Content Type with a unique name.

image

Creating the new External Content Type in SharePoint Designer

(2) Define the External System that the External Content Type is reading data back from – the SharePoint Designer allows a external system to be defined from either a .NET Type, SQL Server or WCF Service.

image

Selectiong the type of connection for the External Content Type

For a simple example of how we can connect SharePoint to CRM we can opt for a SQL Server Datasource that then uses the CRM View to facilitate a read-only connection from CRM to SharePoint using CRM’s Filtered Views.  This provides a direct connection between CRM and SharePoint that maintains the CRM Security Model – however this does need to be Connected as the User’s identity such that the Windows Authentication for the account accessing the SharePoint List is used for accessing the Filtered View.

image

Defining the SQL Database details for the External Content Type's connection

With the underlying connection in place, we can choose which table or view to use as the Data Source – in this case, the view for ‘FilteredContact’.

image

Selecting the SQL View or Table to use as the source data for the External Content Type

(3) Define the Read Item and Read List Operations

With the source data selected, different operations can be defined to be made accessible within SharePoint to effect the data.  In this case using the Filtered View for the Contact entity, we can define simple read-only operations for reading back lists of Contacts or an individual Contact Record into SharePoint.  Initially for reading back a single record from CRM:

image

Defining the Read Item Operation for the External Content Type

Defining this operation within SharePoint allows us to define which fields should be read back from the CRM Datasource when viewing a record of this external type.

Initially to define the unique identifier field to be used:

image

Defining the Unique Identifier for the Read Item Operation

And then to define which other fields should be pulled from the CRM Datasource into the SharePoint External Content Type:

image

Specifying which fields from the source data will be used as part of the External Content Type

With the same being done for the List Operation to ensure that the SharePoint External Content Type can be used for showing either individual records or lists of records within SharePoint.

(4) Set Permissions for the External Content Type

With the two basic read operations defined, our last step to configuring the External Content Type is to define which SharePoint users will have permissions to view data from the External Content Type, to do this we must access the External Content Type page from within the SharePoint Web Application as opposed to the SharePoint Designer.

This is done by opening the SharePoint Central Administration area and then browsing Application Management, Manage Service Applications and then Business Connectivity Services.  This then opens the Web Interface for adding or making changes to External Content Types in the same fashion as we have been doing through the SharePoint Designer.

Selecting the External Content Type we wish to modify will then bring up a modification form for the External Content Type – which includes a ribbon button for ‘Set Object Permissions’.  This brings up a prompt to select which Users or Groups should be able to access data through the External Content Type.

image

Adding a particular Active Directory Group or User to have access to work with the External Content Type

This will then be shown in the SharePoint Designer underneath the Permissions tab:

image

How the resulting Object Permissions are shown in SharePoint Designer

(5) Create a SharePoint List to present the External Content Type

With the connection and e are able to create a new SharePoint List based from this External Content Type to make this data available in the standard SharePoint List format:

image

Creating a new SharePoint List to present the External Content Type within SharePoint

NOTE: If at this step you receive a ‘No Finders available in the View Group’ error, this is a generic SharePoint Designer error which can have many causes – in regards to using CRM Data as an external content type for SharePoint this is often related to using the calculated view fields such as ‘accountidname’ that SharePoint then struggles to incorporate into the Content Type.

With the List created we should now have a External Content Type linked to a particular SharePoint List with associated user interface:

image

The resulting SharePoint List connected to the External Content Type

Which also now appears in the list of SharePoint Lists in the SharePoint Designer:

image

The resulting SharePoint List shown in the 'List of Lists' within SharePoint Designer as a External List

From here we have a list of data within SharePoint that is synchronised with a particular CRM entity – such that any data recorded within CRM is accessible via SharePoint:

image

The final List shown within SharePoint, listing the Contact records held in Dynamics CRM

This List can then be modified as per any other SharePoint List to modify the View Columns or Sort Order.

3. Using the External Data within other SharePoint Lists

This external content list in SharePoint can then be used within other SharePoint-only lists as a lookup – providing a method for using reference data pulled from CRM to store data solely within SharePoint via a Lookup field type.

image

Adding a new Lookup field based on the External CRM List on a separate SharePoint Expense List

Allowing entries to be recorded in the list against a list of lookup records which is being synchronised from CRM.

image

Selecting a CRM Contact within SharePoint to be used as the value of the Lookup field in this separate Expense list

Allowing the selection of the lookup value from the list of CRM records, either via automatic text resolution or a lookup window:

image

The Lookup Selector Window in SharePoint showing the list of CRM Contacts available for selection

In effect allowing the selection of a particular CRM Contact for each Expense, in effect building an association between the SharePoint Expense record (in this case, an expense) and the CRM Contact record – bridging the two systems relatively seamlessly.

image

The resulting Item Record in the separate Expense List, linked back to the CRM Contact record through the external list.

This then allows us to effectively synchronise data between CRM (or any other SQL, .Net or WCF system for that matter) into SharePoint, and then put this data to use in SharePoint via linked lists or reporting – further allowing SharePoint to be a ‘one-stop-shop’ of data from around an organisation.

4. Custom Actions

In addition to showing CRM Data within a SharePoint List we can add actions within SharePoint that can act to manipulate the data – in a simple case this can be simple as opening the CRM Form for the selected record from the SharePoint List.

To do this we can define a Custom Action that opens a dynamics CRM URL, which we can add into the SharePoint External Content Type by browsing to the Content Type within the Business Connectivity Services

image

Viewing the External Content Type in the SharePoint Web Interface

This will bring up a New Custom Action form where we can define what this particular action will do – in this simple case, providing the URL in CRM that the Action should open and any dynamic properties (such as the Record Id for the record in CRM that should be opened) that should be supplied to the URL.

image

Adding a Custom Action to the External Content Type through the SharePoint Web Interface

SharePoint’s Custom Action format for parameters allows a parameter to be defined from any of the fields in the External Content Type as a Parameter No – this Parameter No can then be used in the URL via supplying the number as {0}, {1} and so on.  So with ‘contactid’ defined as parameter {0} we can use the following URL to dynamically open the correct CRM Form URL:

http://[CRMServer]:5555/CRMReports/Viewer/DrillOpen.aspx?ID={0}&LogicalName=contact

This then adds the action to new instances (such as lists) where the External Content Type is used within SharePoint:

image

The Custom Action shown within the SharePoint List for each item.

Clicking this action will then open the Contact record within MSCRM:

image

Opening the record in CRM 2011 as a result of the action in SharePoint

5. Conclusion and References

This post outlines how to use the Business Data Connectivity Services Application in SharePoint 2010 to incorporate data from Dynamics CRM into a SharePoint List – but why would we want to do this?  The simple answer is to continue the SharePoint principle of encompassing a one-stop-shop of data throughout an organisation – in this fashion CRM Data can be constantly accessible from within a SharePoint site for publication and reporting outside the standard CRM User Group.

When we consider how SharePoint List Data can then be used within other areas of SharePoint, particularly within Search, this gives a powerful outlet for sharing data and incorporating CRM Data into the central business intelligence of an organisation.

This can be a powerful step to ensuring that SharePoint is the joining piece for integrating an organisation’s data into a single place across many possible disparate systems – and providing a single venue for Content Management and Reporting.  In subsequent posts I may aim to expand on this further, in terms of how a Business Solution can incorporate SharePoint as the ‘hub’ for the business’s individual systems whether they be CRM, Accounting/ERP, HR or indeed any other operational systems.

The following post from the MSDN Magazine was the inspiration for my revisiting this area of SharePoint, and is an excellent read on the topic:

http://msdn.microsoft.com/en-us/magazine/ee819133.aspx

Posted in CRM 2011, Integration, MSCRM, SharePoint | Tagged , , , , , | 10 Comments

CRM 2011 Integration with SharePoint: Custom Document Management

The previous post on CRM and SharePoint integration focused on looking at the workings of the default CRM 2011 functionality to see how the underlying structure of SharePoint Site and SharePoint Document Location records could cater for much more than the basic ‘out-of-box’ Document Management.

This article aims to describe how we can leverage this flexibility via custom development to define a more bespoke Document Management solution between SharePoint 2010 and CRM 2011, using different arrangements of Document Libraries, Folders and an initial look at Metadata.

Developing a Plugin to integrate CRM to SharePoint

Towards achieving a custom format of Document Management between CRM and SharePoint, we can look at creating a Plugin which will automatically integrate a new CRM Record with a new SharePoint Document area for a particular entity or entities in CRM.

This is similar to how custom Document Management Integrations were often implemented between CRM 4 and SharePoint 2007, however with the advent of SharePoint 2010 we are able to use the SharePoint Client Object Model to make this development simpler and less code-heavy. The aim here being to focus on the desired business logic of our Document Management and not get bogged down with the coding for the SharePoint development.

However our first difficulty here is incorporating the SharePoint Client Object Model DLL in the CRM Plugin to allow us to communicate remotely with our deployment of SharePoint 2010. CRM Plugins are standalone DLLs which are then registered to the Database which makes referencing external DLLs such as the SharePoint Client Object Model difficult – however this can be done via a variety of methods:

(1) Register the Plugin DLL via Disk, and then store both the Plugin DLL and SharePoint Client Object Model DLL in the Bin folder of the CRM Website.

This is functional solution to the problem but in impossible for Online or IFD Deployments of MSCRM.

(2) Merge the SharePoint Client Object Model DLL into your Plugin DLL to form a composite Plugin.

This is almost a functional solution, however the merge makes the Plugin DLL very large and often too large to correctly register with CRM – and is a bit of a hammer to crack to a nut really.

(3) Place the SharePoint Client Object Model DLL in the GAC for the Plugin DLL to reference.

This is the most practical solution as allows us to register our Plugin to the Database – but we have no access to the GAC for Online and usually limited access to the GAC for IFD Deployments of CRM.

(4) Develop the Plugin to call out to either a Webservice which can then access SharePoint.(either one of the standard SharePoint Webservices or a custom Webservice which can then invoke the SharePoint Client Object Model)

This is a workable solution for CRM Online deployments but does require SharePoint to be publically facing to accept the Webservice calls – the best bet in this scenario would be to have CRM Online communicating to Public Webservice which in turn communicates to SharePoint Online.

For this example, we will look into option (3) of using the GAC, as this is likely the most appropriate option of On-Premise deployments of CRM.

Adding the SharePoint Client Object Model DLL to the GAC

Assuming we have access to our CRM and SharePoint Servers, adding the Client Object Model DLL to the GAC is easily done.

First of all we can find the SharePoint DLL on the following location of our SharePoint Server where can take a copy for use on the CRM Server – C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI.

image

The location of the SharePoint Client Object Model on a SharePoint 2010 Server

There is then various ways of adding these DLLs to the GAC, but the simplest is simply to use Windows Explorer to add the files to the following location on the CRM Server – C:\Windows\Assembly.

image

The SharePoint Client DLLs added to the GAC

With these DLLs copied into the GAC, we should be ready to develop a new CRM Plugin which incorporates the Share Point Client Object Model as a reference.

Referencing SharePoint DLLs in Visual Studio

Referencing the SharePoint Client Object Model DLLs in Visual Studio

Developing the Plugin

For the Plugin to create a new Document Library for each new Account, the logic of the Plugin’s execute method will need to carry out the following steps.

(1) Check whether the Account (or other record in CRM) already has a Document Location associated.

(2) If not, then create a new Document Library in SharePoint

(3) Associate the Account in CRM to the newly created Document Library by creating a new SharePoint Document Location record in CRM.

These steps will involve methods that communicate to both CRM and SharePoint, such that the Plugin will break down into three distinct sets of code: methods to retrieve/insert data to CRM, methods to insert data to SharePoint and the core Plugin Execute call that uses these methods to carry out the logic.

If initially we look at how the code could implement this core logic:

#region Plugin Business Logic

string recordName = string.Empty;
Guid recordId = Guid.Empty;

if ( crmAccount.Attributes.Contains(entityIdField) )
{
    recordId = (Guid)crmAccount.Attributes[entityIdField];
}
else
{
    throw new Exception("CrmConsultancy.CRM2011.CustomDocumentManagement.SharePointIntegration :: Could not find a '" + entityIdField + "' attribute for the " + crmAccount.LogicalName + " record");
}

bool createDocumentLibrary = false;

if (crmMethods.DoesCRMRecordHaveSharePointLocation(recordId) == false)
{
    createDocumentLibrary = true;
}

if (createDocumentLibrary == true)
{
    if (crmAccount.Attributes.Contains(entityNameField))
    {
        recordName = (string)crmAccount.Attributes[entityNameField];
    }
    else
    {
        throw new Exception("CrmConsultancy.CRM2011.CustomDocumentManagement.SharePointIntegration :: Could not find a '" + entityNameField + "' attribute for the " + crmAccount.LogicalName + " record");
    }

    SPSite connectedSite = crmMethods.GetDefaultSPSite();
    if (connectedSite != null)
    {
        // create the Document Library in SharePoint
        SharePointMethods sharePointMethods = new SharePointMethods(connectedSite.AbsoluteUrl, "mySharePointUserAccount", "myPassword", "myDomain");

        string documentLibraryName = sharePointMethods.CreateDocumentLibrary(recordName, "Document Library for CRM Record");

        Guid newSharePointLocationId = crmMethods.AddRootSharePointLocation(connectedSite.Id, entityLogicalName, recordId, recordName, documentLibraryName);

    }
    else
    {
        throw new Exception("CrmConsultancy.CRM2011.CustomDocumentManagement.SharePointIntegration :: CRM is not configured for SharePoint Document Management");
    }

}
else
{
    // CRM Record is already connected to a SharePoint Document Location
    // likely no need to create and link to a new location, take no further action
}

#endregion

We can see here the basic Plugin logic for determining the Record Id and Name from the Account via a Post Image, and using these fields to carry out the logic via calls to either CRM Methods or SharePoint Methods.  The highlighted lines in the code above then refer to the points where these calls are made, if we look at these in turn:

DoesCRMRecordHaveSharePointLocation(recordId)

Method to determine whether the CRM Record already has a related Share Point Document Location associating the record to an area in SharePoint. This is essentially simple query in CRM to return a true/false flag depending on whether a record is found.

internal bool DoesCRMRecordHaveSharePointLocation(Guid recordId)
{
    try
    {
        ColumnSet cs = new ColumnSet(new string[] { "sharepointdocumentlocationid", "name" } );

        ConditionExpression regardingCondition = new ConditionExpression("regardingobjectid", ConditionOperator.Equal, recordId);
        ConditionExpression stateCondition = new ConditionExpression("statecode", ConditionOperator.Equal, 1);

        FilterExpression f = new FilterExpression(LogicalOperator.And);
        f.Conditions.Add(regardingCondition);
        f.Conditions.Add(stateCondition);

        QueryExpression q = new QueryExpression("sharepointdocumentlocation");
        q.Criteria = f;
        q.ColumnSet = cs;

        EntityCollection crmLocations = _service.RetrieveMultiple(q);

        if (crmLocations.Entities.Count > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    catch (Exception ex)
    {
        throw new Exception("CrmMethods -> DoesAccountHaveSharePointLocation (" + ex.Message + ")");
    }
}

GetDefaultSPSite()

Method to retrieve the details of the Default SharePoint Site that is connected to CRM via the Document Management area of CRM – this provides the Plugin with the SharePoint URL and ‘root location’ to invoke for calling SharePoint, again however, this is a fairly simple query in CRM to retrieve the relevant record.

internal SPSite GetDefaultSPSite()
{
    try
    {
        ColumnSet cs = new ColumnSet(SPSite.ColumnSet);

        ConditionExpression c = new ConditionExpression("isdefault", ConditionOperator.Equal, true);

        FilterExpression f = new FilterExpression(LogicalOperator.And);
        f.Conditions.Add(c);

        QueryExpression q = new QueryExpression("sharepointsite");
        q.Criteria = f;
        q.ColumnSet = cs;

        EntityCollection crmSites = _service.RetrieveMultiple(q);

        if (crmSites.Entities.Count > 0)
        {
            return new SPSite(crmSites[0]);
        }
        else
        {
            // no SharePoint Sites defined in CRM
            throw new Exception("CRM does not have any default SharePoint Sites");
        }
    }
    catch (Exception ex)
    {
        throw new Exception("CrmMethods -> GetDefaultSPSite (" + ex.Message + ")");
    }
}

new SharePointMethods(connectedSite.AbsoluteUrl, “administrator”, “myPassword”, “MyDomain”)

This constructor methods creates the initial connection to SharePoint using the Absolute Url field from the [GetDefaultSPSite] method alongside valid security credentials. These credentials could be hard-wired in the code, or added to the SharePoint Site entity in CRM as custom fields.

internal SharePointMethods(string spSiteUrl, string spUsername, string spPassword, string spDomain)
{
    try
    {
        _siteUrl = spSiteUrl;
        _clientContext = new ClientContext(_siteUrl);

        _clientContext.Credentials = new System.Net.NetworkCredential
            (spUsername, spPassword, spDomain);
    }
    catch (Exception ex)
    {
        throw new Exception("SharePointMethods.Constructor --> [" + ex.Message + "]");
    }
}

CreateDocumentLibrary(recordName, “Document Library for CRM Record”)

This method is where the Plugin calls out to SharePoint using the Client Object Model to create a new Document Library.

public string CreateDocumentLibrary(string documentLibraryName, string documentLibraryDescription)
{
    try
    {
        Web web = _clientContext.Web;

        _clientContext.Load(web);
        _clientContext.ExecuteQuery();

        ListCreationInformation lci = new ListCreationInformation();
        lci.Title = documentLibraryName;
        lci.Description = documentLibraryDescription;
        lci.TemplateType = 101;

        List newDocumentLibrary = web.Lists.Add(lci);

        newDocumentLibrary.ContentTypesEnabled = true;
        newDocumentLibrary.Update();
        _clientContext.ExecuteQuery();

        return (_siteUrl + "/" + documentLibraryName);
    }
    catch (Exception ex)
    {
        throw new Exception("SharePointMethods.CreateDocumentLibrary('" + documentLibraryName + "') (General Exception: " + ex.Message + ")");
    }
}

AddRootSharePointLocation(connectedSite.Id, entityLogicalName, recordId, recordName, documentLibraryName)

This method adds a new Share Point Document Location record into CRM that associates the regarding object (in this case the Account record) to the new SharePoint Document Library via setting the Relative Url property the name of the new Document Library.

internal Guid AddRootSharePointLocation(
    Guid siteId,
    string regardingEntityType,
    Guid regardingRecordId,
    string regardingRecordName,
    string relativeUrl)
{
    try
    {
        Entity sharepointLocation = new Entity("sharepointdocumentlocation");

        sharepointLocation.Attributes.Add("name", "SharePoint Location for " + regardingRecordName + "");

        EntityReference lookupSharePointSite = new EntityReference(SPSite.EntityName, siteId);
        sharepointLocation.Attributes.Add("parentsiteorlocation", lookupSharePointSite);

        EntityReference lookupRegarding = new EntityReference(regardingEntityType, regardingRecordId);
        sharepointLocation.Attributes.Add("regardingobjectid", lookupRegarding);

        sharepointLocation.Attributes.Add("relativeurl", relativeUrl);

        return _service.Create(sharepointLocation);
    }
    catch (Exception ex)
    {
        throw new Exception("CrmMethods -> AddSharePointLocation (" + ex.Message + ")");
    }
}

This combination of the Plugin Business Logic, CRM Methods and SharePoint Methods then provides a basic Plugin for automatically integrating CRM and SharePoint each time a new Account (or other CRM entity) is created.

The full Visual Studio Solution and code listing can be found here.

Testing the Plugin

With the Plugin registered against CRM, we can then create a new Account in CRM and immediately have a new Document Library created in SharePoint (via the Client Object Model call) and linked into CRM without any further user action:

image

Creating the new Account in CRM 2011

Therefore upon saving the Account, we can browse to the Documents area to view the Documents and Folders in SharePoint via the newly created Document Location record:

image

Automatically created Document Location for the new Account

With this Document Location looking at a new Document Library in SharePoint as opposed to the standard folder inside a pre-existing Library:

image

Document Library within SharePoint 2010

This gives us a method of effectively controlling how we want our documents managed in SharePoint – in that we are no longer fixed into the default behaviour of creating a new Folder for each Account in a single Document Library, instead the custom Plugin has implemented a new system of creating a separate Document Library per Account.

However whilst this control of the Document Management structure is useful, this simply changes the way SharePoint behaves alongside CRM – our next step could be to bring more sophisticated SharePoint functionality into our Plugin as way of leveraging SharePoint’s strong Document Management features alongside CRM.

Namely Content Types.

CRM, SharePoint and Content Types

To provide a brief summary, Content Types are SharePoint’s method for allowing different kinds of Document to be stored with varying Metadata fields based on the Content Type involved.  In a way similar to CRM’s concept of different entities but with a heavier focus on inheritance.

So a Contract Document may have Metadata fields describing the Contract Type, Sent Date, Effective Dates and Compliance Contact; whereas a Proposal may have different fields for Proposal Type, Revision Number and so on – but both would have standard Document fields for Title, Last Modified and Last Modified By.

In SharePoint terms, this would be expressed as two Content Types for Contract and Proposal inheriting from the base Document Content Type.

Normally Document Libraries created in SharePoint have the Content Type functionality deactivated until explicitly activated in the Advanced Settings of the Document Library.

image

Therefore any Document Libraries created by the CRM 2011 SharePoint integration will not initially have this enabled – however with our Plugin now creating the Document Libraries via code, this can be changed to activate Content Types for each new Document Library created via the Plugin.

newDocumentLibrary.ContentTypesEnabled = true;
newDocumentLibrary.Update();
_clientContext.ExecuteQuery();

This would allow the Plugin to create new Document Libraries that are able to be attached to different Content Types. If we then create some Content Types in SharePoint, we can then extend this code to attach the Content Types we want to be accessible in this Document Library:

image

With this done we can alter the code that creates the Document Library to automatically make use of these Content Types for uploading documents:

newDocumentLibrary.ContentTypes.AddExistingContentType(someContentType);
newDocumentLibrary.Update();
_clientContext.ExecuteQuery();

To do this for the Contract Type and Proposal Content Types we have added, our code would have to loop through the Content Types defined in the SharePoint Site and, if found, add them to the Document Library in the same fashion:

_clientContext.Load(web.ContentTypes);
_clientContext.ExecuteQuery();

ContentType proposalContentType = null;
ContentType contractContentType = null;
for (int n = 0; n != web.ContentTypes.Count; n++)
{
    if (web.ContentTypes[n].Name == "Proposal")
    {
        proposalContentType = web.ContentTypes[n];
        _clientContext.Load(proposalContentType);
    }
    if (web.ContentTypes[n].Name == "Contract Type")
    {
        contractContentType = web.ContentTypes[n];
        _clientContext.Load(contractContentType);
    }
}

_clientContext.ExecuteQuery();

if (proposalContentType != null)
{
    newDocumentLibrary.ContentTypes.AddExistingContentType(proposalContentType);
}
if (contractContentType != null)
{
    newDocumentLibrary.ContentTypes.AddExistingContentType(contractContentType);
}

newDocumentLibrary.Update();
_clientContext.ExecuteQuery();

This would have the effect of associating each new Document Library with the predefined Content Types – presenting CRM Users with the option of a different set of metadata fields when adding or uploading a document in CRM:

image

Creating a new document of a different Content Type to SharePoint through CRM

The key here, as with many of SharePoint’s features, being the tight integration with Office to provide the user a seamless transition between CRM and managing the document:

image

Creating a new Document in Office directly from CRM with the SharePoint Metadata fields

With the normal SharePoint functionality for uploading existing documents as specific Content Types as well:

image

Entering the Metadata when uploading a document to SharePoint through CRM

image

Viewing the list of documents with different Content Types in CRM

This gives us a basic custom structure for how different types of documents may be stored using Document Libraries between CRM and SharePoint – essentially a new custom document management configuration for the CRM Solution through a fairly small amount of custom development.

Conclusion

This concept of using CRM Development to control the Document Management between CRM and Sharepoint allows us a great deal of flexability in how documents for a CRM Solution could be structured.

As we have seen here this allows a Solution Architect to consider other methods of goverance when storing documents provide the initial folder-per-entity structure that CRM provides by default. The inclusion of SharePoint Metadata then allows this to be taken one step forward towards SharePoint best practise for managing volumes of documents – essentially providing methods for taking unstructured document data and streamlining this into a structure that fits the business. (or in a more snappy way, working the way you do, and not you working the way the software does)

Moving beyond this, for the next article in this series I will aim to look into how the concept of SharePoint Metadata can be used alongside CRM for SharePoint Views and Templates to further extend a custom document management configuration, and begin to looking at how we could handle the migration of legacy data into CRM and SharePoint.

Source Code

Download from Public-facing Skydrive

Posted in CRM 2011, Development, MSCRM, SharePoint | Tagged , , , , | 36 Comments

CRM 2011 Integration with SharePoint: Taking a Deeper Look

One of the best new additions to CRM 2011 is tight integration with SharePoint 2010 for storing documents.  In the past when using v3 or v4, CRM Projects have been forced to develop custom code to integrate CRM with SharePoint, but now the standard CRM functionality allows the two products to be integrated and easily configured in the CRM 2011 settings area.

Following the CTP and release of 2011 at the beginning of this year, many great articles have been written and posted on the web to provide step-by-step guides for connecting CRM to SharePoint using this functionality:

http://blogs.msdn.com/b/crm/archive/2010/10/08/crm-with-sharepoint-integration-introduction.aspx

http://blog.pointbeyond.com/2011/04/30/integrating-sharepoint-2010-with-crm-2011-for-document-storage/

However as with many areas of ‘out-of-the-box’ functionality the default integration is limited in certain ways.  This article aims to take a deeper look at this integration between CRM 2011 and SharePoint to examine how the integration works ‘under the hood’; with the aim of understanding how CRM 2011 has implemented this integration and how it could be extended further to meet the requirements of more complex Document Management scenarios.

The Standard CRM and SharePoint Document Integration

By default whenever CRM 2011 has been correctly configured to work with SharePoint 2010, an admin user will be able select which CRM Entities should have SharePoint document areas:

image

Configuring Document Management Settings in CRM 2011 by selecting which entities should have a Document Library Folder

Selecting these entities will then have the effect of creating a SharePoint Document Library for each entity:

image

Completing the configuration of Document Management in CRM

image

The resulting Document Libraries creating in SharePoint as a result of configuring CRM 2011's Document Management settings.

Within CRM this will also create a reference in the CRM Database’s Share Point Site table to record that this SharePoint Site will be used for document management – essentially storing the details required to link CRM and SharePoint in this record for reference.  We can see this record via a simple Advanced Find in CRM on the ‘SharePoint Sites’ entity:

image

Running an Advanced Find in CRM for the 'SharePoint Sites' entity to return a single record detailing the settings configured for Document Management with SharePoint

To fully understand how this is connecting the two systems, it can be useful to look at how CRM has populated the fields for this record as the placeholder that CRM has created to act as a pointer to SharePoint:

image

We can also open this record in a similar fashion to any other CRM record:

image

Opening the SharePoint Site record in CRM

With this in place, we can now browse to any valid CRM Record for the entities selected for Document Management and click ‘Documents’ to begin creating or uploading documents against that record.

image

Accessing the Documents area for a CRM Record which does not have an associated SharePoint Document Location record - prompting CRM to offer the option of creating a new folder in SharePoint.

This prompts CRM to create a new SharePoint Folder in the Document Library for the entity type of the record – typically the Account entity in many business cases.

image

The resulting folder for the CRM Account Record created in the 'account' Document Library in SharePoint

With this folder being directly accessible from within CRM via the SharePoint List Component:

image

The Documents area in CRM showing the Documents contained in SharePoint for the highlighted 'Documents on Default Site 1' SharePoint Document Location record.

Behind the scenes here CRM has taken the step of invoking SharePoint to create a new folder for the Account record and adding a reference in the CRM Database to link the Account record to this particular SharePoint Document Location.

Again we can view this reference record in the CRM Database via a simple Advanced Find, this time on the ‘SharePoint Document Locations’ entity in CRM’:

image

Running an Advanced Find in CRM against the 'SharePoint Document Locations' entity

This list of Document Locations shows the references that CRM has created to external SharePoint Locations for storing documents.  In this case, a reference to declare that documents for the ‘Account’ entity will be stored at the relative URL for ‘account’ and a second reference to declare that documents for the ‘CRM Consultancy’ Account record will be stored at the relative URL for ‘CRM Consultancy’. 

As this 2nd reference has a parent link to the 1st, this makes the relative URL ‘account\CRM Consultancy’ – and in turn, the 1st Document Location is linked back to the earlier SharePoint Site record and as such the URL is determined as:

[Site Absolute URL] –> [Location 1 Relative URL] –> [Location 2 Relative URL]

In this case ‘http://mySharePointServer/mySite/account/CRM Consultancy’.

We can look at this as a simple ERD Diagram to show the relationships between the entities in CRM and SharePoint:

Document Management ERD between CRM and SharePoint

Entity Relationship Diagram to show the connection between CRM and SharePoint via the SharePoint Site and SharePoint Document Management Entities

Opening the child Document Location record, we can see these links in a similar fashion to any other Parent/Child Lookup relationship in CRM:

image

Opening the SharePoint Document Location record that links an Account to a folder in SharePoint inside CRM.

Looking at the fields for the SharePoint Document Location entity, we can see that these are very similar to the SharePoint Site entity – particularly when thinking of the AbsoluteUrl/RelativeUrl fields.

image

This series of Site/Location records informs CRM where to look in SharePoint when showing the list of Documents for a record, building a URL from the various levels of relative URLs involved back to the root absolute URL.  This is best expressed by the following Record Relationship Diagram that shows how this functions for an Account in CRM:

CRM - SharePoint Record Relationship Diagram I

Record Relationship Diagram to show how the SharePoint Document Location records associate the Account in CRM to a specific folder within SharePoint

This basic structure of Document Management allows a CRM Users to add new Document Areas for an Account and record Account-based documents directly through CRM.

Folder Structure Entity

The structure above can be extended via the Document Management configuration in CRM to allow for sub-folders from the initial Account folder down to sub-entities such as Contact.  This enables documents to be stored in a nested structure to allow CRM Users to store documents against a Contact or other entity which is in turn linked back to the ‘header’ Account.

Therefore the Record Relationship Diagram would be extended to:

CRM - SharePoint Record Relationship Diagram II

Record Relationship Diagram to show how CRM tracks a variety of SharePoint Document Location records to associate the connected Account and Contact to different linked areas within SharePoint

In this example, the Contact entity could be any entity in CRM that is related to the root Account entity – so we could have additional folders for Opportunity, Order or Case for example.

This extended structure stems from the ‘Folder Structure Entity’ field of the SharePoint Site record, this field can be set to either None, Account or Contact to specify the top-level entity for managing documents.

This defines more complex nested sets of Document Location records in CRM:

[Site Absolute URL] –> [Location 1 Relative URL for Folder Structure Entity] –> [Location 2 Relative URL for Record] –> [Location 3 Relative URL for Sub-Entity] –> [Location 4 Relative URL for Related Record]

image

Looking at the list of SharePoint Document Location records for tracking locations for a Contact attached to a Account when the Account entity is acting as the Folder Structure Entity

This allows CRM to cater for business models where the top-level Customer may be an Account (for business-to-business) or Contact (for business-to-consumer) in a similar fashion to how CRM allows Opportunities or Orders to be linked to either an Account or Contact. 

However by default this is restricted to Accounts and Contacts, we could not have a custom entity or other system entity acting as the Folder Structure Entity – however this does show the flexibilty that Microsoft have built into the concept of Sites and Document Locations.

Conclusion

The crucial understanding here is that this structure of a Document Library per Entity Type with Folder per Entity Record is simply the default business logic provided by CRM 2011 – and is in no way set in stone as the functionality provided by the SharePoint Site and Document Location entities in CRM can easily be extended to provide bespoke business logic for tracking documents.

As with many areas of Dynamics CRM, the application here provides a platform of functionality that can either be used in it’s default configuration or be extended via custom development.

In terms of why we may want to do this, when we look at the standard SharePoint integration here we can see some limitations for Document Management:

  • a single Document Library is storing all the CRM Documents, this could result in a single huge Document Library when it may be better to spread out the documents across multiple document libraries.
  • the Document Structure is heavily dependent on nested folders, this can often create a confusing layout for storing documents; and long-time SharePoint experts generally shy away from heavy use of folders for creating good Document Management governance. (SharePoint Document Libraries and Horrors)
  • Without customising the Document Library in SharePoint, the Document Structure does not make use of SharePoint Views or Metadata for managing documents.

The next post in this series will attempt to show how we can incorporate these concepts into CRM using custom development that uses and builds on these concepts to provide a custom model for managing documents between CRM and SharePoint.

Posted in CRM 2011, Customisation, MSCRM, SharePoint | Tagged , , , | 22 Comments

Tips for Managing CRM Projects

Over the course of working on CRM Projects I have seen a variety of Project Management practices, some very good and some less good – and picked up a good number of tips along the way which I thought I’d try to put into words.

CRM Projects can be very difficult to manage, and this often comes from CRM Projects being thought of and managed as IT Projects, and the difficulty of finding good CRM Consultants that know both know how to understand the business, and how to fit the technology to the business.  Each of these topics could probably easily fit a post all of their own, but for this article am aiming to think more of the Project Management side of things.

Be Consistent – Being a consistent figure in the project who provides a strong sense of how the project will be delivered can go a long way to give the people working on a project a sense of engagement and common goal.

Consistency in how project meetings are run and issues recorded can prevent the feeling that a project is ‘jumping around’ different issues or different problems from week to week.  This lack of consistency can lead to a sense of disconnection for how the project is progressing, and for the people working on the project, to a sense of disengagement from the project itself.

Occasionally with failing projects I have seen the tendency of ‘project bloat’ in a similar fashion to ‘code bloat’ in that the Project Team adopt different methodologies or standards at different points in the project – which can lead to confusion, particularly for outside suppliers or customers of the project who see the project management or meetings running in a different fashion each time they are involved.

This can lead to team members or suppliers becoming disengaged from a project as they do not have confidence that issues or meetings will be managed effectively and so can often favour the approach of simply not raising issues or not speaking up during meetings where they think the project is off-course.  The common symptom is for a valid issue to be raised and recorded, and then simply never addressed again, which leads to a ‘why bother in future’ line of thinking.

The key is to remember that the purpose of a project structure is to provide an environment where the team members can deliver the intended outputs of the project, and a consistent environment goes a long way to this.

The coders and designers are the ones who can be the crazy mavericks in a project, the PM gets to be the lucky one who runs regular structured meetings with these regular issues and consistent reporting, it’s not glamorous but it is effective!

Project Management Methodologies such as PRINCE2 can work to give a Project Manager a set of tools and benchmarks to operate within to provide an established framework for how the project should be managed, which can then keep project time focused on the deliverable itself.

Focus on the Outcomes – A common point for CRM Consultants is the need to focus on the business objectives and not the technology, and projects can be very similar.  There are many different Project Management tools out there for managing time, issues and tasks which can be a big help to a project; but ultimately it can be worth remembering that a project can be well managed using a simple set of spreadsheets. (Methodology not Technology)

Have seen and used a good number of useful Project Management Tools from MS Project, SharePoint, good old Excel, online offerings such as Zoho, various Time Tracking tools and others – all of which have good points and bad points, but ultimately a good project manager sets out their framework using whichever technology and uses it consistently to meet the outcomes of the project. 

Have seen some project managers get side-tracked into looking at all sorts of different technologies to help run the project at different times in the project, and it can quickly become a distraction away from the real outcomes that the executive are looking for the project to deliver.

Be involved, but not that involved – This can be particularly tricky for managers who have progressed from the technical side before moving into management, in that they may have their own opinions of how a design is architected or how development should be implemented.

However a Project Manager has to be careful not to disenfranchise the resources that are working to produce the deliverables for the project by becoming involved in these deliverables.

I have seen cases where a project manager would occasionally jump into the detail of discussing the design of workflow or what fields need to be on a screen – and this can act to throw off the Consultants or Developers working on the project as it becomes unclear who is responsible for what.

For the Project Manager this can then centralise decision making on them that should be being made by the different members of the team, which can lead to the manager being all things to all people and so burning out under the act of getting involved in all areas of the project.

In my opinion the art of a good project manager here is to delegate the project down to the resources involved and trust them to make the decisions that they are responsible for, but still being through in understanding the deliverables that are being produced but not dictating the detail of how these are produced.

In simple terms – if you are the developer, concentrate on developing code to meet the outlined requirements.  If you are the solution architect, then concentrate on specifying the best design for the solution and communicating the requirements down to the developers.  If you are the project manager, then concentrate on managing the project and delegating the specifics. 

This comes down to the age old mixture of being hands-off to a point, without being so hands-off that the project happens by accident; as ultimately the manager always needs to take responsibility for the outcomes.

Audit – At some point somewhere the project executive or stakeholders are going to ask you where money has been spent, and at this point having a well audited project is going to pay dividends, particularly if the project hits a ‘turbulent period’.

No one really likes on-going documentation but a project without this reporting can simply appear as a black hole – in which only the Project Team understand where the costs are going. Unless the standards for how a project will be reported on are established and adhered to, the project can end up simply ‘existing’ without a comparable notation of progress against cost.  This can become increasingly important the longer the project goes on, otherwise we can suffer from the project which runs for years but no one quite knows why or what has been achieved so far.  Have seen and read of a few Public Sector projects which fit this model, which is not to say they are bad projects but more so that the value cannot be seen – particularly if staff on the project or executive change during in the life of the project.

On the more extreme side I have seen projects fail and the only secure final payment due to a complete set of consistent reporting showing that progress was made and agreed to be made – without this, the project manager could have been liable for explaining why that payment was in dispute! 

Beware creating hidden costs – the importance of scope to a Project Manager cannot be underestimated as traditionally a Project Manager will base their estimated costs on the requirements or scope known to date, and these costs communicated back to the executive to inform their decision of whether to proceed with the project. It is therefore crucial to have a full picture of the scope available and that this scope successfully addresses the objective of the project.

I have seen Project Managers paint themselves into a corner by sending information to the executive on the basis of the current scope, whilst knowing that this scope was either incomplete or there were known ‘unknowns’ – which often results in Change Controls being raised that in effect cannot be refused without compromising the project’s ability to meet the original objective, which essentially holds the executive to ransom as the project cannot proceed without the Change Control and hence their original sign-off of costs was in effect not a real picture of the project.

A valid well-defined Project should always be able to continue and meet the original intention of the project without a particular Change Control being authorized –as a valid Change Control should be an addition to the original objective.  If a project cannot meet the objective without a Change Control being authorized, then the project manager is effectively holding a gun to the executive to say that the project cannot continue without the change and additional costs – meaning that the executive have to debate either cancelling the project and wasting whatever money has been consumed to date, or are forced to approve further funds as the project cannot deliver without the change. At this point, this is not a valid change control and rather is the result of the scope of the project not being correctly defined which places both the Project Manager and Executive in a unworkable position that will likely place greater stress on the project.

This concept of not having defined scope for a Project can cripple a project via a resulting loss of confidence in the project.

Internal Resources, they don’t work for you – As a Project Manager, people do not work for you – managing a project will involve assigning tasks and using different resources, however you should be assigning well-defined areas of responsibility and not just giving people tasks.  This allows for resources to understand their place within a project and the level of freedom their have to manage their deliverable; this can be particularly helpful when an internal resource is involved in a number of different projects with potentially different managers.

If people perceive themselves as working for an individual on a project, they can become more concerned with how best to meet the manager’s expectations as opposed to meeting the requirements for the project – ultimately a good manager wants a resource to best work for the project (or their area of responsibility in the project) and not to keep someone happy.

In some cases a Project Manager can also be a Line Manager for some of the project team – in which case, it can be useful to aim to try to divide yourself between the two roles such that you are either managing the project or managing your employees and not combining the two.  (however I imagine any experienced project manager will be used to wearing a number of different hats at points in their career!)

External Resources, managing suppliers – As well as managing internal resources a CRM Project Manager will usually find themselves managing external suppliers who will be bringing their work to the completion of the project.  This can often lead to Project Management problems concerning the difference between a fixed project budget and variable costs from suppliers.

The real benefit of using a 3rd party is the ability to pass the responsibility of delivery for an aspect or component of the project – such that the 3rd party can quote for the work, specify the metrics of delivery (i.e. has the product been delivered to an acceptable standard or not) and then an agreement to deliver within a time frame.  In this sense the Project Manager can then ‘black-box’ the delivery (and therefore the associated risks) of the component to help them manage the overall complexity of the project.

One common flaw that I have seen with CRM Projects is for a 3rd Party to be engaged purely as outsourced development resources who ultimately have no responsibility for the product they deliver, or have specified their own metrics of success in a way that guarantees success for the 3rd party but not for the Project Manager – which can leave the Project Manager exposed to further costs if the eventual product needs to be taken back to the 3rd party for refinement.  Naturally, having a well-defined scope here is vital in specifying the desired component and specifying each party’s responsibilities within the engagement.

This can be common in CRM Projects where the ultimate product of the project is a CRM Solution and a 3rd party is involved to deliver a CRM System, the gap that may exist between the Business’s CRM Solution and the 3rd Party’s delivered product is then the responsibility of the CRM Project Manager which can then give rise to additional costs that the manager has not anticipated.  In this incidence it can be better to connect the 3rd party with the business or customer in a fashion that allows them to present a specification that the business has agreement with, such that the metrics between the customer and the 3rd party are well understood as opposed to being owned by the Project Manager and so potentially creating this gap.

Ultimately using an external supplier should involve outsourcing a certain level of risk as well as pure resource – or in another way, outsourcing a component to a 3rd party should include the responsibility for delivering the component within defined metrics, as otherwise the 3rd party can profit from the engagement whilst all the risk remains with the project itself which is less than ideal.  In a way this keeps overall responsibility for the project with the project manager but allows components with their associated risks to be delegated to outsourcing providers on a contractual basis as opposed to simply outsourcing for a particular technical skill or resource.  This element of risk differentiates an external supplier from an internal resource in how a Project Manager can manage the engagement.

The other model where a 3rd party simply delivers time and materials is more akin to using an internal resource, just one that happens to work for another company, and should be managed as such.

I imagine discussing the different aspects of managing 3rd party providers (and where freelance Contractors fit into this equation) could take up a post all of its own and there is certainly enough management books also discussing the topic – but I think put simply, it is best to aim that both parties benefit from the engagement such that the risk/benefit ratio is split roughly equal so both parties stand a good chance to profit from the engagement.

Engage and Sell – Projects can often run for a long time, and it is easy for the initial impetuous and momentum of the project to drift away.  One useful skill for a Project Manager is the ability to sell the project back to the executive and to the customer as way of keeping that initial interest in the project alive.

This can be particularly true in CRM Projects where the level of user engagement can be a crucial factor in correctly understanding the business process and henceforth the scope of the deliverable – this can often be the role of the Consultant in the project, but can also often be down to the Project Manager.  Presentations to the user-base or the executive to outline why the project is taking place and the intended benefits can be a crucial step in maintaining this engagement, which can be also be very useful in describing how the project budget has been spent and (in a more sales fashion) be useful for securing future budget.

Have seen projects where this constant engagement has proved key in generating a ‘buzz’ around the project which has massively helped training and user adoption, and in turn helped the project to deliver the intended business outcomes.

 

Often Project Management can be perceived as a step up or a progression to ‘greater things’, but I think managing a project involves a number of different skills and a different mind-set to development or consultancy, and should be treated as neither better or worse really.

A good developer can be every bit as crucial to a project as a good project manager, and should not naturally be assumed to be ‘lower down the food chain’ – as otherwise it gives the incentive for good developers to aim to be project managers for no other reason than chasing money and you can end up gaining a poor manager and losing a brilliant developer; likewise for consultants.

This being more debatable than many blog postings is very much subject to opinion, but is some of my collected thoughts from managing or consulting on a good number of CRM Projects.

Thankfully I have been involved with mostly good successful projects but am obviously drawing on experiences with more tricky projects as well, so please feel free to drop me a line or comment if you have any thoughts on this list.

Posted in Project Management | Tagged , , | 1 Comment

Tips for improving the User Experience in Dynamics CRM

Dynamics CRM provides a powerful set of features to tailor a solution’s appearance for a particular client or business model, however as these features do not correspond to functionality these can be overlooked. As the focus of a project can often be on functional requirements or business process, the non-functional aspects of the user experience are often nelegected.

However tailoring the appearance of a solution has a massive effect on the end User Experience which can really drive the User Adoption of a CRM Solution – which is (as most CRM Consultants probably tire of saying!) the primary reason for a CRM Project to fail.

This post focuses on these features of Dynamics CRM and how they can be used to best effect.

Use the Site Map to tailor a Solution
Take an example where a Functional Consultant has correctly broken a client’s business model down into individual business areas and mapped out each process area within the Analysis Documentation, we can then structure our CRM Deployment to match these process areas to truly tailor CRM for how we have analysed the client’s business model.

This not only tailors CRM for the Business Model in question, but also gives a direct narrative between the Analysis Documentation and the final solution. In my experience this creates an instant increase in buy-in from the users and stakeholders who were present in the original workshops and (hopefully!) approved the Analysis Documentation, as they should be able to see how this directly translates into the solution.

Hide Areas that are not used in a Solution
It is rare that a client will attempt to use all the various areas and entities that MSCRM presents – it can be very useful to hide these to keep the solution as simple as possible for the end-users.

This can be done easily using the MSCRM Security Roles, or alternatively by editing the SiteMap XML.

Icons Icons Icons..
Most MSCRM Solutions involve the use of custom entities – however if it is again quite rare to see graphic icons given to these custom entities, instead we tend to see the default MSCRM custom entity icon reused for all the custom entities and screens added into the solution. Icons instantly give a graphical feel which helps convey a cleaner fresher appearance for a solution that can help build a strong User Experience.

When we put all this together:

Tailored MSCRM

Dynamics CRM 4 tailored specifically for a particular business model

Which gives us a much more clean tailored appearance that should be more easily familiar to the User than the default appearance of MSCRM:

Default MSCRM Appearance

The Default Appearance of Dynamics CRM 4

Obviously this only forms a small part of the User Experience which is key for winning user adoption for a CRM Solution. However these little techniques for customising Dynamics CRM can provide the user with a direct correlation between the areas described in a Functional Specification and the end-solution.

And if your requirements analyais or functional specification does not have a concept of the User Experience and how the business process will be reflected in the CRM Solution (whether it be Dynamics or otherwise) then it probably should – but that is a different topic!

Posted in Consultancy, Customisation, MSCRM | Tagged , | Leave a comment