FetchXML 2011–Total Record Count

Fetch in 2011 has added some really nice features.  One of those nice features is the total record count of the applied filter.  In 4.0 you had to execute two fetch statements, but now with 2011 you can add the ReturnTotalRecordCount attribute.

<fetch mapping='logical' count='25' returntotalrecordcount='true'>
<entity name='account'>
<attribute name='accountid' />
<attribute name='accountnumber' />
<attribute name='address1_city' />
<attribute name='address1_telephone1' />
<attribute name='name' />
<order attribute='name' />
<filter>
<condition attribute='address1_city' operator='like' value='Greenville%' />
</filter>
</entity>
</fetch>

 

Upon executing this fetch statement with the ReturnTotalRecordCount  attribute set to true, the “TotalRecordCount” is returned.

image

 

Note: This is not the total number of entities, it is the total number of records that match the filter.