【问题标题】:Count Aggregate in FetchXML reportFetchXML 报告中的计数聚合
【发布时间】:2016-09-07 08:17:58
【问题描述】:

尝试使用 VS2012 按照此处的说明为 CRM 2016 创建 FetchXML 报告:Create a new report using SQL Server Data Tools。我只想找到两个日期之间创建的案例计数。

这些说明讨论了从 CRM 高级查找过程中复制/粘贴下载的 FetchXML。

高级查找过程生成的 FetchXML 列出所有案例(按票号):

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="incident">
    <attribute name="incidentid" />
    <attribute name="ticketnumber" />
    <order attribute="ticketnumber" descending="false" />
    <filter type="and">
      <filter type="and">
        <condition attribute="createdon" operator="on-or-after" value="2015-07-01" />
        <condition attribute="createdon" operator="on-or-before" value="2016-06-30" />
      </filter>
    </filter>
  </entity>
</fetch>

我找不到使用 Advanced Find 进行聚合的方法,但此处的说明:Use FetchXML aggregation 似乎表明只需对 XML 进行一些属性更改。

所以,我将 notepad++ 中的 FetchXML 更改为:

aggregate="true" >
      
        
        aggregate="count" alias="casecount" />
        过滤器>
        过滤器>
      实体>
    

这会导致错误:

要么我做错了,要么 FetchXML 聚合页面不正确。

谁能告诉我如何创建一个 fetchXML 报告来计算两个日期之间打开的案例?

【问题讨论】:

    标签: visual-studio-2012 sql-server-data-tools fetchxml dynamics-crm-2016


    【解决方案1】:

    您不能在进行聚合的同时选择一个属性 (incidentid)。

    此外,在聚合时应用排序没有意义。

    我已经删除了这两行,之后 FetchXML 就可以运行了:

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" aggregate="true" >
      <entity name="incident">
        <attribute name="ticketnumber" aggregate="count" alias="casecount" />
        <filter type="and">
          <filter type="and">
            <condition attribute="createdon" operator="on-or-after" value="2015-07-01" />
            <condition attribute="createdon" operator="on-or-before" value="2016-06-30" />
          </filter>
        </filter>
      </entity>
    </fetch>
    

    附带说明一下,您可能希望使用XrmToolBox 中的 FetchXml 测试器来快速编辑和执行 FetchXML。

    【讨论】:

    • 谢谢。一旦我在 VS 中重新创建了报告,这就完成了工作。我不确定 eventid 是如何选择的,我只是使用了高级查找,它给了我这些字段。
    猜你喜欢
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-21
    • 2013-09-24
    • 1970-01-01
    相关资源
    最近更新 更多