Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

unable to get subgrid record count on load of form in CRM HUB UI

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: unable to get subgrid record count on load of form in CRM HUB UI

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: unable to get subgrid record count on load of form in CRM HUB UI

    yes it is checked

  • Suggested answer
    gdas Profile Picture
    gdas 50,087 on at
    RE: unable to get subgrid record count on load of form in CRM HUB UI

    Hi Purnima,

    Can you please check the Tab properties and make it by default expanded.

    tab.JPG

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: unable to get subgrid record count on load of form in CRM HUB UI

    yes ..it is giving right count on grid load event but for that i have to click on tab ..

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: unable to get subgrid record count on load of form in CRM HUB UI

    Try registering it on grid load event.

    docs.microsoft.com/.../subgrid-onload

    Hope this helps.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: unable to get subgrid record count on load of form in CRM HUB UI

    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?

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: unable to get subgrid record count on load of form in CRM HUB UI

    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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: unable to get subgrid record count on load of form in CRM HUB UI

    ya..it is giving 0,but I have 3 records associated

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: unable to get subgrid record count on load of form in CRM HUB UI

    I tested it on CRM Hub which is Unified interface.

    Possiblly a caching issue, try different browser/ incognito mode.

    Hope this helps.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: unable to get subgrid record count on load of form in CRM HUB UI

    Records are there..its giving right count   on classic UI but on interactive ui its giving 0

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.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,996 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans