Hi,
I am unable to get subgrid record count on load of form in CRM HUB UI. I am using following javascript to get record count. It's working fine in classic ui,but its not working in HUB UI (returning record count 0,which is wrong).
function getTotalGridRecordCount()
{
debugger;
var functionName="onLoad";
try{
setTimeout( function(){
if (Xrm.Page != null && Xrm.Page != undefined && Xrm.Page.getControl("Contacts") != null && Xrm.Page.getControl("Contacts") != undefined) {
var count=Xrm.Page.getControl("Contacts").getGrid().getTotalRecordCount();
alert(count);}},5000);
}
catch(e)
{
Xrm.Utility.alertDialog(functionName + "Error: " +e.message || e.description);
}
}
*This post is locked for comments
Are you saying the tab is already opened but the grid load even is triggering when you click on tab? If the tab is closed then the subgrid will not load and hence the event will not trigger.
yes it is checked
Hi Purnima,
Can you please check the Tab properties and make it by default expanded.
yes ..it is giving right count on grid load event but for that i have to click on tab ..
Hi Ravi,
Is your subgrid is in first tab? I just moved my subgrid from tab2 to tab1 there its giving correct count but when i keep subgrid in tab 2 then its giving 0.In hub 1 tab loads at a time that's why...so is there any work around for it?
This is strange, for me the code is working as expected. Can you increase the timer from 5 sec to say 10/ 15 seconds? Wondering if it has anything to do with the load of subgrid
ya..it is giving 0,but I have 3 records associated
I tested it on CRM Hub which is Unified interface.
Possiblly a caching issue, try different browser/ incognito mode.
Hope this helps.
Records are there..its giving right count on classic UI but on interactive ui its giving 0
André Arnaud de Cal...
291,996
Super User 2025 Season 1
Martin Dráb
230,853
Most Valuable Professional
nmaenpaa
101,156