我想返回一个父记录(Quote)及其所有子记录(Quote Details +链接的实体Product),以在使用Fetch XML的报表中使用。我目前使用的是父报表-子报表结构,但是我需要访问父报表中存储在产品上的数据。
我试图创建适合这种情况的Fetch XML查询,但是我只能编写一个查询,该查询返回预过滤的Quote标头,但返回所有Quote Details,无论它属于哪个报价。
当前的父报表获取XML:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="quote" enableprefiltering="1" prefilterparametername="CRM_FilteredQuote">
<attribute name="name" />
<attribute name="customerid" />
<attribute name="statecode" />
<attribute name="totalamount" />
<attribute name="discountpercentage" />
<attribute name="description" />
<attribute name="new_productsubgroupid" />
<attribute name="new_masterproductgroupid" />
<attribute name="quotenumber" />
<attribute name="ownerid" />
<attribute name="createdon" />
<attribute name="quoteid" />
<attribute name="effectiveto" />
<attribute name="effectivefrom" />
<order attribute="quotenumber" descending="true" />
</entity>
</fetch>
当前的子报表获取XML:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="quotedetail">
<attribute name="productid" />
<attribute name="productdescription" />
<attribute name="priceperunit" />
<attribute name="quantity" />
<attribute name="extendedamount" />
<attribute name="quotedetailid" />
<order attribute="productid" descending="false" />
<filter type="and">
<condition attribute="quoteid" operator="eq" uitype="quote" value="@QuoteId" />
</filter>
<link-entity name="product" alias="product" to="productid" from="productid" link-type="outer" visible="false">
<attribute name="price" />
</link-entity>
</entity>
</fetch>
我尝试进行组合查询(返回单个报价,但返回所有报价详细信息,无论父级如何):
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >
<entity name="quote" enableprefiltering="1" prefilterparametername="CRM_FilteredQuote" >
<attribute name="name" />
<attribute name="customerid" />
<attribute name="statecode" />
<attribute name="totalamount" />
<attribute name="discountpercentage" />
<attribute name="description" />
<attribute name="new_productsubgroupid" />
<attribute name="new_masterproductgroupid" />
<attribute name="quotenumber" />
<attribute name="ownerid" />
<attribute name="createdon" />
<attribute name="quoteid" />
<attribute name="effectiveto" />
<attribute name="effectivefrom" />
<order attribute="quotenumber" descending="true" />
<link-entity name="quotedetail" alias="quoteProduct" to="quoteid" from="quoteid" link-type="outer" enableprefiltering="1" prefilterparametername="CRM_FilteredQuote" >
<attribute name="productid" />
<attribute name="productdescription" />
<attribute name="priceperunit" />
<attribute name="quantity" />
<attribute name="extendedamount" />
<attribute name="quotedetailid" />
<order attribute="productid" descending="false" />
<link-entity name="product" alias="product" to="productid" from="productid" link-type="outer" visible="false" >
<attribute name="price" />
<attribute name="new_submittleurl" />
</link-entity>
</link-entity>
</entity>
</fetch>
答案 0 :(得分:0)
请尝试以下查询, 我更改的是link-type =“ inner” 以前您使用的是外部,因此它返回了所有甚至没有链接且与产品详细信息相同的报价详细信息。
让我知道这是否对您有用。
您也可以在xrmtoolbox插件fetchxmlbuilder中尝试使用此fetchxml。
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >
<entity name="quote" enableprefiltering="1" prefilterparametername="CRM_FilteredQuote" >
<attribute name="name" />
<attribute name="customerid" />
<attribute name="statecode" />
<attribute name="totalamount" />
<attribute name="discountpercentage" />
<attribute name="description" />
<attribute name="new_productsubgroupid" />
<attribute name="new_masterproductgroupid" />
<attribute name="quotenumber" />
<attribute name="ownerid" />
<attribute name="createdon" />
<attribute name="quoteid" />
<attribute name="effectiveto" />
<attribute name="effectivefrom" />
<order attribute="quotenumber" descending="true" />
<link-entity name="quotedetail" alias="quoteProduct" to="quoteid" from="quoteid" intersect="true" enableprefiltering="1" prefilterparametername="CRM_FilteredQuote" >
<attribute name="productid" />
<attribute name="productdescription" />
<attribute name="priceperunit" />
<attribute name="quantity" />
<attribute name="extendedamount" />
<attribute name="quotedetailid" />
<order attribute="productid" descending="false" />
<link-entity name="product" alias="product" to="productid" from="productid" intersect="true" visible="false" >
<attribute name="price" />
<attribute name="new_submittleurl" />
</link-entity>
</link-entity>
</entity>
</fetch>