我正在为Dynamics CRM构建SSRS报告,因此我必须使用FetchXml。例如,我有10个帐户,我必须从第二个查询中减去5个帐户。
我准备了2个fetchxml报告参数:
10个帐户的CRM_FilteredAccount
我必须减去的帐户的CRM_FilteredAccountNeg
我有如下所示的数据集。
到目前为止的数据集:
<fetch distinct="false" useraworderby="false" no-lock="false" mapping="logical" >
<entity name="account" enableprefiltering="1" prefilterparametername="CRM_FilteredAccount" >
<attribute name="name" alias="name" />
</entity>
</fetch>
(不工作)带有不同参数的链接实体的数据集:
<fetch distinct="false" useraworderby="false" no-lock="false" mapping="logical" >
<entity name="account" enableprefiltering="1" prefilterparametername="CRM_FilteredAccount" >
<attribute name="name" alias="name" />
<link-entity name="account" enableprefiltering="1" prefilterparametername="CRM_FilteredAccountNeg" from="accountid" to="accountid" link-type="outer" alias="neg" >
<filter>
<condition entityname="neg" attribute="accountid" operator="null" />
</filter>
</link-entity>
</entity>
</fetch>
我期望第一个filterparametet给出10个帐户的结果。然后使用带有第二个filter参数的link-entity,只剩下5个帐户的结果。
好吧,让我们做类似下面的事情:第一个数据集让我们称之为“否定”对于这个数据集,使用fetchxml检索帐户,其中帐户ID不为空。该数据集将为我们提供5条记录。现在对于这个数据集,我们将accountid字段使用此字段作为参数,并且调用是“NegativeAccounID”,即它将包含必须从我们的下一个fetchxml中排除的所有帐户的Guid
现在第二个数据集,让我们称之为“结果”对于这个数据集,使用fetchxml检索所有帐户,其中accountid not eq NegativeAccountId(参数)我们定义。
这将为您提供准确的结果。
您将不得不使用参数如何工作。