我提交了一个我无法解决的小问题。也许它会在未来帮助某人。
我正在使用 BIDS 2008 和 Dynamics CRM 2011。
我刚刚开发了一个基于 FetchXML 的报告(客户要求)。此外,我使用表达式作为我的数据集查询,例如:
= 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>"
)
目的是根据参数值返回一个虚拟值(第二次查询)而不是正常值(第一次查询)。
在 Visual Studio 的预览模式下一切正常。我可以查看和使用两个查询中的值。
但由于某种原因,当尝试在 Dynamics 中部署此报告时,我收到 Malformed FetchXML 错误(详情如下)。实际上,当我将表达式替换为正常的 FetchXML 值时,报表部署良好。实际上,我可以放置任何有效的 FetchXML,即使它在我的报告上下文中没有意义,它也会部署!所以真正的问题是不被识别为有效 XML 的表达式。
知道如何让 Dynamics 接受我的基于表达式的数据集吗?
这是错误日志:
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>