Description:
In this example we explain that how to count number of records in
Dynamic CRM and display it in a form or entity. In this example we explain that
how to get total number of contacts in Dynamic CRM.so to get total count
records below is the code for that
int totalCount = 0;
QueryExpression query = new QueryExpression("contact");
query.ColumnSet = new ColumnSet();
query.Distinct = true;
query.ColumnSet.AddColumn("contactid");
query.PageInfo = new PagingInfo();
query.PageInfo.Count = 5000;
query.PageInfo.PageNumber = 1;
query.PageInfo.ReturnTotalRecordCount = true;
EntityCollection entityCollection = orgService.RetrieveMultiple(query);
totalCount = entityCollection.Entities.Count;
while (entityCollection.MoreRecords)
{
query.PageInfo.PageNumber += 1;
query.PageInfo.PagingCookie = entityCollection.PagingCookie;
entityCollection = orgService.RetrieveMultiple(query);
totalCount = totalCount + entityCollection.Entities.Count;
}
MessageBox.Show(totalCount.ToString());
0 comments:
Post a Comment