【问题标题】:FetchXML Filters With Different Entities具有不同实体的 FetchXML 过滤器
【发布时间】:2013-04-10 05:20:46
【问题描述】:

我希望使用 fetchXML 过滤器过滤我在 CRM2011 中的实体。但是,我在使用 AND 和 OR 对不同实体进行分组时遇到了问题。

我正在根据客户的同意搜索客户,其中每个客户将拥有 1 个或 0 个有效同意。如果没有有效的同意,我想退回客户。我也希望客户在征得同意的情况下返回,但如果在没有指定机构的情况下获得“受限”同意(例如,client.consent.type == 'restricted' AND client.consent.users CONTAINS user),则不需要返回

到目前为止,我有这个:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
  <entity name="contact">
    <attribute name="fullname" />
    <attribute name="thr_verifiedproofofidentity" />
    <attribute name="thr_interpreterrequired" />
    <attribute name="emailaddress1" />
    <attribute name="thr_consent" />
    <attribute name="birthdate" />
    <attribute name="thr_individualreferencenumber" />
    <attribute name="contactid" />
    <order attribute="fullname" descending="false" />
    <filter type="and">
      <condition attribute="statecode" operator="eq" value="0" />
      <condition attribute="thr_consent" operator="not-null" />
    </filter>
    <link-entity name="thr_consent" from="thr_clientid" to="contactid" alias="aa">
      <filter type="and">
        <filter type="or">
          <condition attribute="thr_consenttype" operator="eq" value="130120003" />
          <condition attribute="thr_consenttype" operator="ne" value="130120003" />   *
        </filter>
      </filter>
      <link-entity name="thr_thr_consent_thr_agency" from="thr_consentid" to="thr_consentid" visible="false" intersect="true">
        <link-entity name="thr_agency" from="thr_agencyid" to="thr_agencyid" alias="ab">
          <filter type="and">
            <condition attribute="thr_agencyid" operator="eq" uiname="Test" uitype="thr_agency" value="(agency id goes here)" />   *
          </filter>
        </link-entity>
      </link-entity>
    </link-entity>
  </entity>
</fetch>

此代码中唯一缺少的是,我需要使用“*”对两个条件属性市场进行 AND 分组。

这个可以吗?

【问题讨论】:

  • 您可以先使用高级查找创建查询,然后下载 fetchxml。在高级查找表单中,还有 OR、AND 分组选项
  • 此代码是使用高级查找表单生成的,但是该表单不允许对不同实体进行分组。起初我试图使用 QueryExpressions,但我也无法让它工作。我想要 FetchXML 或 QueryExpressions 的原因是搜索使用了很多实体的通用代码,并且在通用搜索运行之前需要先输入查询。
  • “很多实体的通用代码”和“在通用代码运行之前需要先‘输入’查询是什么意思?”

标签: dynamics-crm-2011 fetchxml


【解决方案1】:

正如 Guido Preite 指出的那样,使用高级查找来创建 Fetch Xml 会更容易,而不是手动编辑它。

但是……

由于您没有进行任何分组,我建议您甚至不要使用 Fetch Xml,而是使用其他受支持的 SDK 选项之一(QueryExpressions、Linq to CRM、oData 等)。

我不确定我是否完全理解您的请求(如果您可以将查询编写为 SQL 语句,那将会很有帮助),但我认为您需要有 link-type="outer" 的 2 个 thr_consent 链接实体。第一个具有等于 130120003 的条件,第二个具有指向代理 id 条件的链接。

【讨论】:

    猜你喜欢
    • 2016-05-30
    • 2020-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-09
    • 2017-01-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多