Dynamics crm fetchxml 分组依据

Dynamics crm fetchxml group by

我想知道每个用户的任务总数。比如John Smith 562,Elsa Taylor 953等。我试过这个fetchxml,但是结果只是任务总数:

<fetch aggregate="true" >
  <entity name="task" >
    <link-entity name="systemuser" from="systemuserid" to="ownerid" >
      <attribute name="fullname" alias="fullname" aggregate="count" />
    </link-entity>
  </entity>
</fetch>

我怎样才能做到这一点?

您需要切换查询并select(并按)系统用户全名并计算任务数:

<fetch aggregate="true" >
  <entity name="systemuser" >
    <attribute name="fullname" alias="fullname" groupby="true" />
    <link-entity name="task" from="ownerid" to="systemuserid" link-type="inner" alias="t" >
      <attribute name="activityid" alias="numberoftasks" aggregate="count" />
    </link-entity>
  </entity>
</fetch>