链接不是“主要”实体的实体

问题描述 投票:1回答:1

我被要求使用FetchXML从CRM创建一些数据报告。我之前从未使用过这种语言,所以我认为这可能是一个简单的问题。

我有以下代码:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="bie_backbonus" enableprefiltering="1">
    <attribute name="bie_backbonuscontractno" />
    <attribute name="bie_backbonusnoteforletter" />
    <attribute name="bie_offdate" />
    <attribute name="bie_ondate" />
    <attribute name="bie_backbonuscontractversion" />
    <attribute name="bie_backbonuscontractname" />
    <attribute name="bie_backbonuscontactname" />
    <attribute name="bie_legacybackbonuscode" />
    <attribute name="owneridname" />
    <attribute name="createdon" />
<link-entity name="bie_backbonusproductgroup" from="bie_backbonuscontractno" to="bie_backbonusid" alias="pg" link-type="outer">
    <attribute name="bie_tier2percent" />
    <attribute name="bie_tier2value" />
    <attribute name="bie_tier3percent" />
    <attribute name="bie_productsubtype" />
    <attribute name="bie_tier1value" />
    <attribute name="bie_tier3value" />
    <attribute name="bie_producttype" />
    <attribute name="bie_tier1percent" />
 </link-entity>
<link-entity name="bie_producttype" from="bie_name" to="bie_producttype" alias="p" link-type="outer">
    <attribute name="bie_producttypenl" />
</link-entity>
  </entity>
</fetch>

我试图链接上面的三个实体,但是bie_producttype实体需要链接到bie_backbonusproductgroup实体而不是bie_backbonus,我认为它是。是否有一种功能或方式链接到“主要”实体以外的其他实体?

我也尝试过使用http://www.sql2fetchxml.com/,但这产生了我的报告无法读取的代码。

我是一个SQL Developer,如果用SQL编写,代码就是这样:

SELECT  b.bie_backbonuscontractno
   ,b.bie_backbonusnoteforletter 
   ,b.bie_offdate
   ,b.bie_ondate
   ,b.bie_backbonuscontractversion
   ,b.bie_backbonuscontractname
   ,b.bie_backbonuscontactname
   ,b.bie_legacybackbonuscode
   ,b.owneridname
   ,b.createdon
   ,pg.bie_tier2percent
   ,pg.bie_tier2value
   ,pg.bie_tier3percent
   ,pg.bie_productsubtype
   ,pg.bie_tier1value
   ,pg.bie_tier3value
   ,pg.bie_producttype
   ,pg.bie_tier1percent
   ,p.bie_producttypenl
FROM bie_backbonus b
JOIN bie_backbonusproductgroup pg ON pg.bie_backbonuscontractno =    b.bie_backbonusid
JOIN bie_producttype p ON p.bie_name = pg.bie_producttype

在此先感谢您的帮助。

xml dynamics-crm crm fetchxml
1个回答
1
投票

可以在FetchXML中嵌套link-entity。当查看上面的查询时,看起来你最外层都有link-entity,这就解释了为什么它会像你期望的那样加入bie_backbonus而不是bie_backbonusproductgroup

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="bie_backbonus" enableprefiltering="1">
    <attribute name="bie_backbonuscontractno" />
    <attribute name="bie_backbonusnoteforletter" />
    <attribute name="bie_offdate" />
    <attribute name="bie_ondate" />
    <attribute name="bie_backbonuscontractversion" />
    <attribute name="bie_backbonuscontractname" />
    <attribute name="bie_backbonuscontactname" />
    <attribute name="bie_legacybackbonuscode" />
    <attribute name="owneridname" />
    <attribute name="createdon" />
<link-entity name="bie_backbonusproductgroup" from="bie_backbonuscontractno" to="bie_backbonusid" alias="pg" link-type="outer">
    <attribute name="bie_tier2percent" />
    <attribute name="bie_tier2value" />
    <attribute name="bie_tier3percent" />
    <attribute name="bie_productsubtype" />
    <attribute name="bie_tier1value" />
    <attribute name="bie_tier3value" />
    <attribute name="bie_producttype" />
    <attribute name="bie_tier1percent" />
    <!-- ↓ This has been moved inwards -->
    <link-entity name="bie_producttype" from="bie_name" to="bie_producttype" alias="p" link-type="outer">
        <attribute name="bie_producttypenl" />
    </link-entity>
    <!-- ↑ This has been moved inwards -->
 </link-entity>
  </entity>
</fetch>
© www.soinside.com 2019 - 2024. All rights reserved.