FetchXML: get count of records based on a field of a linked entity

十年热恋 提交于 2019-12-06 07:29:05

The answer is

<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true' aggregate='true'> 
<entity name='client'> 
<attribute name='clientid' alias='PersonName' groupby='true' /> 
<link-entity name='locationadd' from='clientid' to='clientid' alias='aa'> 
<attribute name='isthiscurrentadd' alias='Count' aggregate='count'/> 
<filter type='and'> 
<condition attribute='isthiscurrentadd' operator='eq' value='1'/> 
</filter> 
</link-entity> 
</entity> 
</fetch>

Try following - this code will return you the number of clients.

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" aggregate="true">
<entity name="client">
<attribute name="clientid" aggregate='count' alias='clientscount'/>
<link-entity name="locationadd" from="clientid" to="clientid" alias="aa">
  <attribute name="locationadd" aggregate="countcolumn" />
  <filter type="and">
    <condition attribute="isthiscurrentadd" operator="eq" value="1"/>
  </filter>
  </link-entity>
  </entity>
</fetch>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!