Thursday, June 16, 2011

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=5.0.0.0, 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:

http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
  -2147188072
  http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
  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.
  2011-06-16T07:43:12.1856313Z
 
 


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

http://support.microsoft.com/kb/2491352

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
www.crmkonsulterna.se

Wednesday, June 01, 2011

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")]
[ReferenceTarget("new_specialentity")]
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

www.crmkonsulterna.se