Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Accessing grid data

(0) ShareShare
ReportReport
Posted on by 795

Can i access particular column of a subgrid while using online dynamics CRM?

*This post is locked for comments

  • CRM Beginner  Profile Picture
    CRM Beginner 795 on at
    RE: Accessing grid data

    Yes Sure..

     function dynamicallyFilterSubGrid()  {

      var objSubGrid = Xrm.Page.getControl("My Timesheets");

       if (objSubGrid == null || objSubGrid.readyState != "complete") {

           setTimeout(dynamicallyFilterSubGrid, 1000);

           return;

       }

        else {

           var start = new Date(Xrm.Page.getAttribute("new_startdate").getValue()).toISOString();

           var end = new Date(Xrm.Page.getAttribute("new_enddate").getValue()).toISOString();

           var FetchXml = "<fetch distinct='false' mapping='logical'  aggregate='true' output-format='xml-platform' version='1.0'>" +

                               "<entity name='new_timesheet'>" +

                                   "<attribute name='new_name'/>" +

                                   "<attribute name='new_project' alias='project_name' groupby='true' />" +

                                   "<attribute name='new_startdate'/>" +

                                   "<attribute name='new_enddate'/>" +

                                   "<attribute name='new_timesheetstatus'/>" +

                                   "<attribute name='new_billablehours' alias='billable_sum' aggregate='sum' />" +

                                   "<order descending='false' attribute='new_billablehours'/>" +

                                    "<link-entity name='new_timesheet' from='new_timesheetsid' to='new_billingid' alias='billing'>"+

                                   "<filter type='and'>" +

                                       "<condition attribute='new_startdate' value='" + start + "' operator='ge'/>" +

                                       "<condition attribute='new_enddate' value='" + end + "' operator='le'/>" +

                                    "</filter>" +

                                   "</link-entity>"+

                               "</entity>" +

                           "</fetch>";

           objSubGrid.control.SetParameter("fetchXml", FetchXml);

           objSubGrid.control.Refresh();

       }

    }

  • Nithya Gopinath Profile Picture
    Nithya Gopinath 17,076 on at
    RE: Accessing grid data

    Can you share the javascript code you have written?

  • CRM Beginner  Profile Picture
    CRM Beginner 795 on at
    RE: Accessing grid data

    Sir, Can i access the data using OData call and then filter it using FetchXml..Is it possible ?

  • CRM Beginner  Profile Picture
    CRM Beginner 795 on at
    RE: Accessing grid data

    Sir, for me everything is giving null

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,076 on at
    RE: Accessing grid data

    You can access subgrid as shown below.

    var subGridCtrl = Xrm.Page.getControl("SubgridName");

    But the problem is that in order to do filtering of rows, you should use the code below which is unsupported.

    var subGridCtrl = window.parent.document.getElementById("SubgridName");

    See: nishantrana.me/.../unsupported-filtering-of-subgrids-in-dynamics-365-crm-2016

  • CRM Beginner  Profile Picture
    CRM Beginner 795 on at
    RE: Accessing grid data

    So, instead of this,how do we access subgrid then?

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,076 on at
    RE: Accessing grid data

    By the line above, you are retrieving only the subgrid, not the data. Also, note that document.getElementById("Subgridname") is unsupported. lease follow the code in my above thread.

  • CRM Beginner  Profile Picture
    CRM Beginner 795 on at
    RE: Accessing grid data

    Sir, one thing more..

    While retrieveing data from another entity in the current subgrid after filtering records, in the line -:

    document.getElementById("Subgridname") //Current entity's subgrid or the data which we are retrieveing ?

    What we use inside?

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,076 on at
    RE: Accessing grid data

    Hi,

    You can write the following function with a timeout.

    function AccessSubgrid() {
    
        var subGridCtrl = Xrm.Page.getControl("SubgridName");
    
        // If subgrid is not loaded yet, then call same function after some time.
        if (subGridCtrl == null) {
            setTimeout(AccessSubgrid, 1000)
            return;
        }
    
        // Code for accessing the subgrid data once the subgrid load is completed
    subGridCtrl.getGrid().getRows();
    }

    Hope this helps.

  • CRM Beginner  Profile Picture
    CRM Beginner 795 on at
    RE: Accessing grid data

    Thanks for the reply Sir..But the issue is while onload the subgrid is null.So it returns null..How to resolve this isssue?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,307 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans