Question

I am submitting a little problem I am unable to solve. Maybe it will help somebody in the future.

I am working with BIDS 2008 and Dynamics CRM 2011.

I just developed a FetchXML-based report (client requirement). Also, I used expressions as my dataset queries, such as:

= IIf(Parameters!strLob.Label = "Consulting",
"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'><entity name='opportunity'><attribute name='mcs_internalreferrer' /><order attribute='mcs_internalreferrer' descending='false' /><link-entity name='mcs_lob' from='mcs_lobid' to='mcs_lobid' visible='false' alias='lob'><attribute name='mcs_name' /><!-- lob_mcs_name --><filter type='and'><condition attribute='mcs_name' operator='eq' value='Consulting' /></filter></link-entity><filter type='and'><condition attribute='mcs_internalreferrer' operator='not-null' /></filter></entity></fetch>",
"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'><entity name='mcs_option'><attribute name='mcs_key' alias='mcs_internalreferrerValue'/><attribute name='mcs_value' alias='mcs_internalreferrer'/><filter type='and'><condition attribute='mcs_key' operator='eq' value='reports_param_na' /></filter></entity></fetch>"
)

The purpose is to return a dummy value (2nd query) instead of the normal values (1st query), depending on the parameter value.

Everything works fine in Visual Studio's preview mode. I can see and use values from both queries.

But for some reason, when trying to deploy this report in Dynamics, I get an Malformed FetchXML error (details below). Indeed, when I replace the expression with a normal FetchXML value, the report deploys fine. Actually, I can put any valid FetchXML, even if it makes no sense in my reporting context, it deploys! So really the problem is the expressions, that are not recognized as valid XML.

Any Idea how I could make Dynamics accept my expression-based datasets?

Here is the error log:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Command text is invalid.Detail: 
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
  <ErrorCode>-2147220733</ErrorCode>
  <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
    <KeyValuePairOfstringanyType>
      <d2p1:key>CallStack</d2p1:key>
      <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">   at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
   at Microsoft.Crm.Extensibility.Pipeline.Execute(PipelineExecutionContext context)
   at Microsoft.Crm.Extensibility.MessageProcessor.Execute(PipelineExecutionContext context)
   at Microsoft.Crm.Extensibility.InternalMessageDispatcher.Execute(PipelineExecutionContext context)
   at Microsoft.Crm.Extensibility.ExternalMessageDispatcher.ExecuteInternal(IInProcessOrganizationServiceFactory serviceFactory, IPlatformMessageDispatcherFactory dispatcherFactory, String messageName, String requestName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, ParameterCollection fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId, Guid transactionContextId, Int32 invocationSource, Nullable`1 requestId, Version endpointVersion)
   at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.ExecuteRequest(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)
   at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)</d2p1:value>
    </KeyValuePairOfstringanyType>
  </ErrorDetails>
  <Message>Command text is invalid.</Message>
  <Timestamp>2013-01-29T20:45:56.0253388Z</Timestamp>
  <InnerFault i:nil="true" />
  <TraceText i:nil="true" />
</OrganizationServiceFault>
Was it helpful?

Solution

After some further searching, it seems like it is a limitation of Dynamics CRM 2011.

A short workaround that could work :

  1. Create a Dataset1 and some report elements based on it
  2. Create a Dataset2 and some similar elements based on it
  3. Make these elements visible/hidden based on parameter value

This would give a dynamic look and feel to our FetchXML report.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top