Counting records in CRM can be tricky and time consumption when there are more than 5.000 records in the table. There are several ways and tools to do this that are already well described in the community.
When you are fine with the fact that the numbers you receive are static from a count last night, you can use the RetrieveTotalRecordCount function.
There are descriptions in the community on how to use it, too:
- Natraj shows you how to getting entity record counts in C# and JavaScript
- Nishant uses the RetrieveTotalRecordCount function to get the total number of records in Dynamics 365, only using by an url in a browsers address bar
I combined both and created a bookmarklet, so that you don’t need to to memorize the url path or modify a bookmark everytime when you are in a different system or need another table (entity).
The RetrieveTotalRecordCount Bookmarklet
Create a normal bookmark in you browser and replace its url with the following code:
javascript:function proc(){var r = JSON.parse(this.responseText).EntityRecordCountCollection,t = [];for (let i = 0; i < r.Keys.length; i++) {t.push(r.Keys[i]+"="+r.Values[i])}prompt("Result", t.join(","))} etn = prompt("EntitySchemaName as CSV?", "account,contact").split(",").map((str) => str.replace(/\s/g,''));var oReq = new XMLHttpRequest();oReq.addEventListener("load", proc);oReq.open("GET","api/data/v9.1/RetrieveTotalRecordCount(EntityNames=['"+etn.join("', '")+"'])");oReq.send();
You can use it at any place inside of D365 CE. You only need to write in a SchemaName of an entity (table) or several, comma separated SchemaNames and it answers you with the EntitySetName and the number of records in it (counted last night).