简体   繁体   中英

Dynamics crm fetchxml group by

I would like to have the total number of tasks for each user. For example, John Smith 562, Elsa Taylor 953, etc. I tried this fetchxml, but the result is just the total number of tasks:

<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>

How can I accomplish this?

You need to switch your query around and select (and group by) the systemuser fullname and count the tasks:

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM