Currently I am trying to retrieve count of parent records where condition is governed by linked entity record. When I am trying to run fetchxml without any aggregation record count is coming fine , but when I try to do aggregation it is coming different and bigger in number. on analysis found out that count is taking values from linked entity . Has anyone faced this kind of issue. Following is my fetchxml query :
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" aggregate="true">
<entity name="abc_entity">
<attribute name="abc_name" alias="EntityName" aggregate="countcolumn"/>
<attribute name="createdon" alias="createdonyear" groupby="true" dategrouping="year"/>
<attribute name="createdon" alias="createdonmonth" groupby="true" dategrouping="month"/>
<attribute name="createdon" alias="createdonweek" groupby="true" dategrouping="day"/>
<filter type="and">
<condition attribute="abc_applicationdate" operator="on-or-after" value="@Start_date"/>
<condition attribute="abc_applicationdate" operator="on-or-before" value="@EndDate"/>
<condition attribute="abc_productid" operator="in">
</condition>
</filter>
<link-entity name="abc_entitydocument" from="abc_entityid" to="abc_entityid" alias="av" link-type="inner">
<attribute name="createdon" alias="CreatedDate" aggregate="max"/>
<filter type="and">
<condition attribute="abc_document" operator="not-null"/>
<condition attribute="abc_entityid" operator="not-null"/>
</filter>
</link-entity>
</entity>
</fetch>
Eg. In abc_entity I have linked entity as abc_entitydocument where abc_entitydocument are multiple for each abc_entity. I only want to take count as 1 for those cases which gives me correct count of records.
Thanks