Sample: Use aggregation in FetchXML
This sample shows how to retrieve aggregate record data using FetchXML.
What this sample does
The FetchXML
query is intended to be used in a scenario where it creates queries to get the data.
How this sample works
In order to simulate the scenario described in What this sample does, the sample will do the following:
Setup
- Checks for the current version of the org.
- The
CreateRequiredRecords
class creates 3 opportunity records and account record.
Demonstrate
- The
estimatedvalue_avg
fetches the average of estimatedvalue for all the opportunities. TheEntityCollection
method returns the results of theRetrieveMultiple
request. - The
opportunity_count
fetches the count of all opportunites. - The
estimatedvalue_max
fetches the maximum estimatedvalue of all opportunites. - The
estimatedvalue_min
fetches the minimum estimatedvalue of all opportunities. - The
estimatedvalue_sum
fetches the sum of estimatedvalue for all opportunities. - The
estimatedvalue_avg2
fetches the multiple aggregate values within a single query. - The
groupby1
fetches a list of users with a count of all the opportunites they own using the groupby. - The
byyear
fetches the aggregate information about all the opportunites that have been won by year. - The
byquarter
fetches the aggregate information about the opportunities that have been won by quarter. - The
bymonth
fetches the aggregate information about the opportunities that have been won by month. - The
byweek
fetches the aggregate information about the opportunities that have been won by week. - The
byday
fetches the aggregate information about the opportunities that have been won by day. - The
byyrqtr
fetches the aggregate information about the opportunities that have been won by year and quarter. - The
byyrqtr2
specifies the result order.
Clean up
Displays an option to delete all the data created in the sample. The deletion is optional in case you want to examine the data created by the sample. You can manually delete the data to achieve same results.