Notifications
Announcements
No record found.
Hi,is it possible the count the number of records of an entity with javascript,can anyone please tell me how to do that if it possible
*This post is locked for comments
I think following post should be able to help you.
http://www.customerdynamics.com/Blog/Get-the-Entities-and-their-Record-Counts-in-Microsoft-CRM/
I would suggest having REST endpoints and not to access Database directly
www.customerdynamics.com/.../Get-the-Entities-and-their-Record-Counts-in-Microsoft-CRM
@Inder Singh Rathore.can you please tell me where i have to put that code.
Hi Youssef,
From which application/Interface/Solution/Form etc you are calling it?
i want call it inside account record
Using XrmServiceToolkit (https://xrmservicetoolkit.codeplex.com/) library, the GetAccountsCount function will return count of all accounts. You can add filters to the fetch to only fetch count of active or inactive accounts.Place the function in a JavaScript file and add it to the form and simple call:
var countofAccounts = GetAccountsCount(); function GetAccountsCount() { var fetchXml = "<fetch mapping='logical' aggregate='true'>" + "<entity name='account'>" + "<attribute name='accountid' aggregate='count' alias='count' />" + "</fetch>"; var result = XrmServiceToolkit.Soap.Fetch(fetchXml, false); if((result) && (result.length) && (result.length > 0)) { return result[0].attributes["count"].value; } // Something is wrong return -1; }
function totalcount() {
var xml = "<fetch version='1.0' mapping='logical' aggregate='true'>" + "<entity name='entityname'>" +
"<attribute name='atributeid'/>" +
"<attribute name='atributeid' aggregate='COUNT' alias='count'/>"+
" </entity>"+"</fetch>";
var userRecords = XrmServiceToolkit.Soap.Fetch(xml);
var count = userRecords[0].attributes.count.value;
alert("Count= " + count);
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2