web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

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

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Dynamics365 Rocker Profile Picture
    7,755 on at

    Please share Java script.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Purnima,

    I have used your exact code (i.e. dint change anything not even the name of the method/ subgrid)  and added to my trial. It is working as expected. As its returning 0 and not -1 I think its not the issue with the code but the record itself has no records.

    Can you check it again?

    Hope this helps.

  • Community Member Profile Picture
    on at

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

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    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
    on at

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

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    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
    on at

    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?

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Try registering it on grid load event.

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

    Hope this helps.

  • Community Member Profile Picture
    on at

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

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Purnima,

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

    tab.JPG

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans