【问题标题】:How to filter using fetch to get accurate results?如何使用 fetch 进行过滤以获得准确的结果?
【发布时间】:2018-05-14 14:33:05
【问题描述】:

我需要在state not open 中获取所有有电话的帐户,所以我创建了一个关于 fetch 的查询并得到了一些结果。

在检查我的结果后,我发现我得到了所有至少有 1 个电话未打开的帐户,但我需要获得 所有他们连接的电话未打开的帐户(可以' t 甚至 1 处于打开状态)是否可以通过 fetch 来完成?

** NOT OPEN 是指已取消或已完成的状态。

这是我的获取查询:

@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
  <entity name='account'>
    <attribute name='name' />                                        
    <order attribute='accountamount' descending='true' />
    <link-entity name='phonecall' from='regardingobjectid' to='accountid' alias='ab'>
      <filter type='and'>
        <condition attribute='statecode' operator='ne' value='0' />
      </filter>
    </link-entity>
  </entity>
</fetch>";

【问题讨论】:

  • 请显示您尝试的查询..
  • @ArunVinoth 我把它添加到我的问题中

标签: filter dynamics-crm fetch dynamics-crm-2016 fetchxml


【解决方案1】:

您正在寻找的是不匹配查询。这可以使用 fetchxml 在 2 个查询中实现。

第一个查询:您必须拉出所有未接电话的帐户。

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >
  <entity name="account" >
    <attribute name="accountid" />
    <order attribute="accountamount" descending="true" />
    <link-entity name="phonecall" from="regardingobjectid" to="accountid" alias="ab" >
      <filter type="and" >
        <condition attribute="statecode" operator="eq" value="0" />
      </filter>
    </link-entity>
  </entity>
</fetch>

第二个查询:迭代第一个查询帐户结果集并将其传递为&lt;value&gt;,如下所示,以过滤掉它们。

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >
  <entity name="account" >
    <attribute name="name" />
    <attribute name="primarycontactid" />
    <attribute name="telephone1" />
    <attribute name="accountid" />
    <order attribute="name" descending="false" />
    <filter type="and" >
      <condition attribute="accountid" operator="not-in" >
        <value><GUID of ACCOUNT1 with OPEN PHONECALL></value>
        <value><GUID of ACCOUNT2 with OPEN PHONECALL></value>
        <value><GUID of ACCOUNT3 with OPEN PHONECALL></value>
      </condition>
    </filter>
  </entity>
</fetch>

Read for idea

【讨论】:

  • Arun ,您的意思是要获得 2 个 Entitycollections :1-所有帐户 2-所有具有未结电话的帐户并从所有帐户中删除所有具有未结电话的帐户?
猜你喜欢
  • 2019-09-20
  • 1970-01-01
  • 2013-10-05
  • 2011-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-24
  • 1970-01-01
相关资源
最近更新 更多