0

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

Daryl
  • 18,592
  • 9
  • 78
  • 145
Manish
  • 19
  • 3
  • If anything your count should be fewer because of `link-type=inner` as parent records with no child records are omitted. Are you sure your count is more when you aggregate? Can you update your question with the response xml in both the cases (aggregate and non-aggregate)? – dynamicallyCRM Nov 16 '16 at 18:46
  • Yes when I use the normal fetchxml it gives me record count based on Parent entity but when I use it in aggregation it gives me record count based on linked entity. – Manish Nov 17 '16 at 06:06

0 Answers0