【发布时间】: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