Я хочу вернуть одну родительскую запись (Цитата) вместе со всеми ее дочерними записями (Сведения о цитате + продукт связанной сущности) для использования в отчете с использованием Fetch XML. В настоящее время я использую структуру родительского отчета-подотчета, но мне нужно получить доступ к данным, которые хранятся в продукте, в родительском отчете.
Я попытался создать XML-запрос Fetch, соответствующий этому сценарию, но мне удалось написать только запрос, который возвращает предварительно отфильтрованный заголовок цитаты, но все сведения о цитате, независимо от того, к какой цитате она принадлежит.
Текущий 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>