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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Get Subgrid Count when records get add to Subgrid

(0) ShareShare
ReportReport
Posted on by 6,211

Hi All,

I want to get the total no of records in subgrid on page load and when

any record gets added to subgrid. Dynamics CRM(8.2 online)

Best Regards,

Shahbaaz

*This post is locked for comments

I have the same question (0)
  • NODAL Profile Picture
    860 on at
    RE: Get Subgrid Count when records get add to Subgrid

    Hi shahbaz,

    No it is not deprecated you can find it in version 8.2 sdk message excel.

    If the relationship is n: n then use this otherwise create and delete message on sub grid entity will work.

  • Suggested answer
    Shahbaaz Ansari Profile Picture
    6,211 on at
    RE: Get Subgrid Count when records get add to Subgrid

    Hi nodal,

    Associate and disassociate message has been deprecated from  crm 2013(please correct me if I'm wrong).

    Thanks,

    Shahbaaz

  • NODAL Profile Picture
    860 on at
    RE: Get Subgrid Count when records get add to Subgrid

    Hi Shahbaaz,

    Can you try a single plugin on association and disassociation message to populate both count and other operation you want to do on count field change.

    Regards,

    Nodal

  • Rawish Kumar Profile Picture
    13,758 on at
    RE: Get Subgrid Count when records get add to Subgrid

    Yes thats correct. In this case, please use Javascript!

  • Shahbaaz Ansari Profile Picture
    6,211 on at
    RE: Get Subgrid Count when records get add to Subgrid

    Thanks for the suggestion, i want to trigger plugin as soon as the i add record in subgrid, will it work with rollup field? because rollup fields are calculated via an Async Process so this might take time.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Get Subgrid Count when records get add to Subgrid

    Hi Shahbaaz ,

    You can call REST API , to get the subgrid data using entity id , I think this is better way to get the total record count .

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: Get Subgrid Count when records get add to Subgrid

    Hi Shahbaaz,

    Above code is fine. However, unlike Calculated fields, you can trigger a plugin on a rollup field. So its up to you if you want to use a rollup field or the javascript :)

  • Verified answer
    Shahbaaz Ansari Profile Picture
    6,211 on at
    RE: Get Subgrid Count when records get add to Subgrid

    Thanks Rawish for the response, i wanted to do it using javascript because i wanted to update a field value and trigger plugin, that wont work with rollup field(please correct if i am wrong).

    I have used below code on page load to get the count of the subgrid using javascript and set timeout so when ever any record gets added to it, it will update the field.

    NOTE : i tried "Xrm.Page.getControl("ZipcodeGrid").getGrid().getTotalRecordCount();" code on editable subgrid and it was not working so i posted the question, then i removed the editable subgrid and used nornal grid and it was working with this code "Xrm.Page.getControl("ZipcodeGrid").getGrid().getTotalRecordCount();"

    Hope this helps someone!!!

    //below is the function

    function GetGridCount()

    var zipcodeSubgridCount = Xrm.Page.getControl("ZipcodeGrid").getGrid().getTotalRecordCount();

    Xrm.Page.getAttribute("ewt_subgridcount").setValue(zipcodeSubgridCount.toString());

    setTimeout("GetGridCount()", 5000);

    }

    Thanks,

    Shahbaaz

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: Get Subgrid Count when records get add to Subgrid

    Hi Shahbaaz,

    How about you use a simple rollup field to count child records?

    community.dynamics.com/.../count-the-number-related-child-records-using-a-rollup-field

    let me know if its something you aint looking for.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans