Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Count Subgrid records using plugin

Posted on by

hi Guys,

how to count subgrid records and store the record count in one field using plugin.It is possible to do using plugin.

thank you

*This post is locked for comments

  • Suggested answer
    Sreevalli Profile Picture
    Sreevalli 3,256 on at
    RE: Count Subgrid records using plugin

    Hi Dinesh,

    you can create a rollup field and have the condition to see the records count. quick help link - community.dynamics.com/.../count-the-number-related-child-records-using-a-rollup-field

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Count Subgrid records using plugin

    hmm , why not you use service.RetrieveMultiple passing subgrid reference and get the result length.

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Count Subgrid records using plugin

    Hi,

    Rollup field cannot fullfill your requirements?

  • DineshRaja Profile Picture
    DineshRaja on at
    RE: Count Subgrid records using plugin

    Thank You Goutam..but i want to do that process in plugin

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Count Subgrid records using plugin

    Hi Dinesh,

    Try with this -

    function getTotalGridRecordCount() {
        debugger;
        try {
    
            setTimeout(function () {
                // Replace Grid name 
                if (Xrm.Page != null && Xrm.Page != undefined && Xrm.Page.getControl("contactopportunitiesgrid") != null && Xrm.Page.getControl("contactopportunitiesgrid") != undefined) {
                    var count = Xrm.Page.getControl("contactopportunitiesgrid").getGrid().getTotalRecordCount();
                    //alert("Total Opportunities:"+count);
                    Xrm.Page.getAttribute("new_fieldName").setValue(calculatedproductfield); // Replace Field Name
                }
            }, 5000);
        }
        catch (e) {
            Xrm.Utility.alertDialog(functionName + "Error: " + e.message || e.description);
        }
    }

    community.dynamics.com/.../count-total-subgrid-records-in-dynamics-crm-using-javascript

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans