I've below FetchXML as SSRS dataset that runs after selection of certain parameter and retrieve Invoice Lines and then Factors (Custom Entity). Factors are being retrieved on the base of report parameters Territory, Selected Product(s), Sales Type and End Time. I want to retrieve only those Factors for a product that is having Invoice Line.
For example if ABC and XYZ are two products selected in Product Parameter and ABC is associated with any number of Invoice Lines while XYZ is not associated with any Invoice Lines. Then no factor should be retrieved against XYZ product.
Please help to get only those factors against product that is having invoice lines against them.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"> <entity name="invoicedetail"> <attribute name="productid" /> <attribute name="productdescription" /> <attribute name="priceperunit" /> <attribute name="quantity" /> <attribute name="extendedamount" /> <attribute name="new_lineamount" /> <attribute name="invoicedetailid" /> <order attribute="productid" descending="false" /> <filter type="and"> <condition attribute="new_product" operator="in" value="@Product" /> <condition attribute="new_ordertype" operator="in" value="@Order_Type" /> </filter> <link-entity name="invoice" from="invoiceid" to="invoiceid" link-type="inner" alias="invoice"> <filter type="and"> <condition attribute="msdynce_invoicedate" operator="on-or-after" value="@goal_start" /> <condition attribute="msdynce_invoicedate" operator="on-or-before" value="@goal_end" /> </filter> <link-entity name="account" from="accountid" to="customerid" link-type="inner" alias="account"> <attribute name="ownerid" alias="agent"/> <filter type="and"> <condition attribute="accountcategorycode" operator="eq" value="1" /> <condition attribute="orb_sanctionliststatuscode" operator="ne" value="169810001" /> </filter> <link-entity name="territory" from="territoryid" to="territoryid" link-type="inner" alias="territory"> <link-entity name="new_factorsetup" from="new_region" to="territoryid" link-type="inner" alias="factor"> <attribute name="new_factor" /> <filter type="and"> <condition attribute="new_product" operator="in" value="@Product" /> <condition attribute="new_salestype" operator="eq" value="@Sales_Type" /> <condition attribute="new_validto" operator="eq" value="@End_Date" /> </filter> </link-entity> </link-entity> </link-entity> </link-entity> </entity> </fetch>
*This post is locked for comments