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

rampprakash_0-1674210056707.png

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 

rampprakash_1-1674210171186.png

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();
            alert(count);
        }
    }, 15000);
}

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

rampprakash_2-1674210958690.png

11. Click Save and Publish

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

rampprakash_3-1674211210777.png

13. Now Add Function in the OnLoad Operation

rampprakash_4-1674211290953.png

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 🙂

rampprakash_5-1674211665753.png

That’s it 🙂

This post was originally published on this site

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

The Total Economic Impact of Microsoft Teams as a Platform

Today, businesses seeking to improve efficiency and deliver on customer commitments are instead struggling with the challenge of stand-alone...

More Articles Like This

- Advertisement -spot_img