Saturday, 16 April 2016

Order by - FetchXML Query

The following FetchXML query shows how to use the aggregate attribute and multiple orderby clauses.
  1. <fetch distinct='false' mapping='logical' aggregate='true'>
  2. <entity name='opportunity'>
  3. <attribute name='opportunityid' alias='opportunity_count' aggregate='count'/>
  4. <attribute name='estimatedvalue' alias='estimatedvalue_sum' aggregate='sum'/>
  5. <attribute name='estimatedvalue' alias='estimatedvalue_avg' aggregate='avg'/>
  6. <attribute name='actualclosedate' groupby='true' dategrouping='quarter' alias='quarter' />
  7. <attribute name='actualclosedate' groupby='true' dategrouping='year' alias='year' />
  8. <order alias='year' descending='false' />
  9. <order alias='quarter' descending='false' />
  10. <filter type='and'>
  11. <condition attribute='statecode' operator='eq' value='Won' />
  12. </filter>
  13. </entity>
  14. </fetch>
Explanation
To create order by FetchXML query:
  • Add order clause in entity and set descending keyword to true or false.
    <order alias='year' descending='false' />
- See more at: http://msxrmtools.com/fetchxml/reference

No comments:

Post a Comment