I am having issues with a FetchXML query running against Dynamics CRM 2013 (online).
When running this simple query
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" count="5">
<entity name="activitypointer">
<attribute name="activityid" alias="activity_id" />
<attribute name="activitytypecode" alias="activity_type" />
<attribute name="ownerid" alias="owner" />
</entity>
</fetch>
I get the expected results for the activity_type column e.g. "email", "opportunityclose" etc.
But when I attempt this aggregate version of the same query
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" aggregate="true">
<entity name="activitypointer">
<attribute name="activityid" alias="activity_count" aggregate="count" />
<attribute name="activitytypecode" alias="activity_type" groupby="true" />
<attribute name="ownerid" alias="owner" groupby="true" />
</entity>
</fetch>
I get the correct results for the activity_count and owner columns, but the "activity_type" column is populated with just "Microsoft.Xrm.Sdk.OptionSetValue" or if ran within a report "#error".
I assume this is something to do with grouping by an option field type.
Does anyone know how to resolve this issue?