Some interesting questions on xRM functionality

I have received a few questions from one of the readers of this blog and I will answer them bellow:

I am currently working on a project which is planning to use CRM 2011 as a development platform for migrating an existing  vertical specific LOB application.  As the existing application has a large and complicated database, I am trying to better understand how CRM 2011 can use external data, hence the following questions:
          Can CRM 2011 use external data assuming it is exposed as an OData feed?

Yes and no. CRM 2011 cannot using some simple mode of configuration connect to an OData feed but there are numerous customizations that can be done using techniques such as javascript, mash-ups, SilverLight, XSLT or ASP.NET that can be used to work with the Odata feed. When I work with my clients, I usually try to understand what they are trying to achieve to be able to recommend a technique that fits their requirements.

          Will CRM allow creation of Metadata for external Odata?

Yes, as mentioned above the different customization points allow for different ways of communicating and working with external data and metadata such as OData. There are no built in methods that automatically will connect OData to CRM (as I know of anyway).

          Can CRM security model be used for external Odata?

The CRM security model is rather complex as it incorporates several concepts at the same time;

o   Security roles
o   Organizational context with ownership of objects based on this and in conjunction with the roles.
o   Sharing privileges to individual users and/or teams

This results in the fact that it is rather complex to replicate the privileges for a certain object to a related object in another system. It can be done, but requires in-depth knowledge of the CRM security model and the API:s as all data related to this can be accessed from the API.

As an example of the complexity, let’s say that you have users A, B and C. User A belongs to division inner sales, user B to division outer sales and user C to division service. All have the same role that only allows access to the accounts within the same division. The account “Vodaphone” is owned by A and A creates a new team to which he shares the rights to view the account “Vodaphone”. He then adds B to this team while creating it. Some time later he adds C to this team as well and shares read-write access directly to B as well.

This is an example that despite the fact that they all have the same roles would involve a lot of setting access rights in the external system since the adding of team members to teams indirectly sets their rights. It is not impossible to implement but quite complex and does require a considerable amount of effort. For an experienced CRM developer, probably not less than 200 hours.

When discussing issues like this with my clients, I, as I usually do, try to understand their core needs and motives so that I can suggest a good-enough solution that will give them the best bang of the buck.

          Does CRM allow the use of external Odata in native forms or custom Silverlight UI has to be developed?

No. Fields (previously called attributes) are directly connected to the database and there is no support for virtual attributes that will retrieve data from an external source.

Integrations to external systems, using any data source, for instance OData, can of course be created that will transfer data to CRM. Data could for instance be periodically sent or sent when there is an update if the external system allows that kind of triggering.

It is also possible to jack into the retrieve or retrieve multiple events that occur when CRM tries to retrieve data so that CRM could pull data from the external data source when data is retrieved. I would not recommend this though since these events occur a lot and it would probably affect performance badly. It is also supported to fetch data directly from the database views using SQL and that would bypass this logic making this data incorrect. This would also cause some problems with working with CRM offline.

The solution you are hinting at using Silverlight is of course also an option but would be similar to some mash-up integration that could also be created using ASP.NET or javascript.

It would sometimes also be an option to create specific reports in CRM that connect to external data sources and integrate the CRM data with the external data in this manner. This method is preferable when using data warehousing or when there are heavy performance issues, as these reports can be cached and scheduled.

Without knowing more about the specific requirements, I would hence recommend some kind of periodic or live integration that transfers the required data to CRM in read-only fields as this would be most in line with how CRM works and would enable all built in features that CRM has to work with this data. It would also be best from a performance perspective and could be scaled if needed.

          Can external Odata be used in Workflow activities?

Yes, custom workflows activities can be created in all versions of Microsoft Dynamics CRM 2011 except CRM Online where the same logic can be created with some work-around effort using plugins instead. These custom workflow activities are created using the .NET framework typically in C# and can hence easily use any available datasource, like Odata.

On a related front, does CRM allow complicated (i.e. highly normalized and multi-level) data hierarchies to be implemented  natively?  If so, is there a performance penalty?  Would we be better off using this data as an external OData feed or bringing it internal to CRM?

No, CRM does not support some of the more complex OO concepts like interfaces and inheritance. As this is something many of us in the CRM community are looking for and it would also be a great addition to the xRM concept so I am certain it is on Microsoft’s list of features they are trying to implement. How far up, I cannot say.

This is usually not a major issue for me when I work with my clients and I have created very complex verticalizations, for instance for the Telco industry which implement a highly normalized and multi-level information model called SID, in CRM. What you need to do is make it a bit more flat and more concrete which you more or less have to do anyway if you want to make the system usable. It is of course important to be well aware of the simplifications you are making but I do not imagine that any usable system possibly could implement the entire SID information model without simplification and still make the system usable and with any reasonable budget. The abstract class “Party” for instance is just too abstract to be of any real use, but it is of course useful to know that contact, account, competitor, lead, system user etc. do share some information. The implementation would however have benefited from one or two inheritances or interfaces.

If the data should be kept in or outside the system is not easy to answer without deeper knowledge of what you are trying to implement. If you keep it mostly outside, you would have to define a very strict line at which information is kept inside or outside of CRM. Do not, however, underestimate the power of the xRM platform, it is often advantageous to implement large or all parts of the LOB application inside CRM/xRM since you get so much functionality for free when doing this.

In general I would need deeper domain knowledge to be able to give you more direct recommendations and I do not think that this is the forum for that kind of discussion as that requires a dialog and would probably best be done in workshops.

I do like the fact that you sent me these questions as I think they are very relevant when looking at the system from an xRM perspective and put the finger on some of the issues that Microsoft have to improve in the system. If there are other readers out there, if you have questions, please send them to me and I will try to answer them on this blog.

Gustaf Westerlund
CEO, Chief Architect and co-Founder at CRM-konsulterna AB

Today I was deploying a solution to a production environment and ran into a quite difficult problem; the custom report we had made could not be uploaded to CRM and the error description was rather cryptic. This error description was independent on if we tried to import the entire solution or just added the report directly. The error we received was the following:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]:

An error occurred while trying to add the report to Microsoft Dynamics CRM. Try adding the report again. If this problem persists, contact your system administrator.Detail:” xmlns=”“>
  -2147188072” />
  An error occurred while trying to add the report to Microsoft Dynamics CRM. Try adding the report again. If this problem persists, contact your system administrator.

I Binged/Googled the webb some and found that this article probably describes this error as it fits our environmen setup:

The error was due to the fact that reports written for SQL 2008 R2 are not compatible with SQL 2008. This has some very important effects as many customers might be running SQL 2008 for the production environments and many developers work with SQL 2008 R2 when developing. This difference might not be noticeable in general but this fact will cause these reports  to not be importable into the production environment.
So, a general suggestion is to have all environments, development, development test, acceptance test, training and production on exactly the same version of both Windows server and SQL-server to avoid any errors showing up in one of the environments but not the other, something that can be very problematic to solve due to the difficulty of finding the error since it by definition cannot be replicated on some of the environments.
Gustaf Westerlund
CEO, Chief Architect and co-Founder at CRM-konsulterna AB

Problem with Custom Workflow Activities in CRM 2011

The workflow activities framework for CRM 2011 has been upgraded from CRM 4.0. The dependance properties have been removed and it now support the simplified datatypes used in CRM 2011 like DateTime.

I was developing a custom activity today and I had an output argument that was of the type EntityReference. However, when I tried to run it I got a weird error:

“The argument of type ‘Microsoft.Xrm.Sdk.EntityReference’ cannot be used. Make sure that it is declared on an activity.”

The argument declaration looked like this:

[Output(“The Output of special entity”)]
public OutArgument specOut { get; set; }

And I am trying to set it with the following code:

specOut = new OutArgument();
Entity outent = entities.Entities[0];
specOut.Set(executionContext, outent.ToEntityReference());

I had also tried creating the entity reference with a default contstructor and filling id and logicalname, with the constructor setting id and logicalname. I had even tried setting it using the entity directly but they all give the same error. I had not found anything useful on the internet or in the SDK.

After some rethinking I looked closer at the error message and thought that there might be something wrong with the declaration or definition of the OutArgument. And after some tries I found that the error was that I had created a new OutArgument which is wrong, it is precreated and this was the reason for the error. Hence I just removed the line:

specOut = new OutArgument();

and it work like it should have from the beginning.

It is always interesting to work with new technology!

Gustaf Westerlund
CEO, Chief Architect and co-Founder at CRM-konsulterna AB

Ignoring system checks during installation of CRM

Sometimes when installing, it can be necessary to allow the installation to take place despite the fact that some of the system checks that are conducted during the installation fail. There are some different places mentioning how to do this, it is actually rather simple, you just have to add the DWORD key IgnoreChecks with a value of “1” to the MSCRM key in the registry [HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSCRM].

Gustaf Westerlund
CEO, Chief Architect and co-Founder at CRM-konsulterna AB

Problems when connecting PluginRegistration Tool to CRM

I was going to deploy some plugins to a server today and when I tried to connect to the CRM with the PlugingRegistration.exe I found got the following error:

Unhandled Exception: System.ServiceModel.FaultException: The server was unable to process the request due to an internal error.

So I switched on the tracing in CRM and read the following from the trace log (edited):

System.IO.FileNotFoundException, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089

Could not load file or assembly ‘Microsoft.Xrm.Client, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified.

The error seems to originate from CRM not being able to find the Microsoft.Xrm.Client.dll file. After some fiddeling, I fixed it by copying the file from the SDKbin directory to CRMWebbin directory. It is a bit strange that it is required that you do this, and it will probably be fixed in future rollups of CRM 2011.

By the way, I heard some rumors from the CRM Statement of Direction that CRM 6 will be released Q2 2012 and that it will have multibrowser support. The feature we have all been waiting for, and it is probably going to be more or less the same thing as the 2011 version but with multibrowser support. So Software Assurance will probably be a good idea this year for Microsoft Dynamics CRM.

Gustaf Westerlund
CEO, Chief Architect and co-Founder at CRM-konsulterna AB