Power Community

Power Community

How to get SubGird Record Count with Webresource in Dynamics CRM

Implementation Steps:

1. Navigate to https://make.powerapps.com

2. Create or Open any Existing Solution

3. Open the Table/Entity where you want to get count of SubGrid in my case am taking Account Table


4. As per the ScreenShot there is 4 Records available so i need to show as a popup with Count as 4

5. So First Step i will take the Sub Grid Name

6. Open the Form where your SubGrid ExistsΒ 


7. Based on the Above ScreenShot the Name of the SubGrid is Contacts

8. Now Lets Start Writing the JavaScript

9. Open Your Visual Studio or VS Code and Write the Below Function

function getsubgridcount(executionContext) {
    setTimeout(function () {
        var formContext = executionContext.getFormContext();
        if (formContext !== null && formContext != "undefined") {
            var accountgridname = "Contacts";
            var count = formContext.getControl(accountgridname).getGrid().getTotalRecordCount();
    }, 15000);

10. Now Create a JavaScript (Web Resource) in CRMΒ 


11. Click Save and Publish

12. Now Open the Same Account Form and Add the JavaScript Library in the Form


13. Now Add Function in the OnLoad Operation


14. Once Done Click Save and Publish

15. Now Open the Account Table and Open a Record you will see the alert message over there πŸ™‚


That’s it πŸ™‚

This post was originally published on this site

- Advertisement -spot_img


Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

Enable Early Access Wave 1 2023 | Power Platform

Like every 6 months, enabling Early Access is one of the best things to look forward to as Microsoft...

More Articles Like This

- Advertisement -spot_img