Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Filter Subgrid based on field value without using fetchXml

(0) ShareShare
ReportReport
Posted on by 40

I want to filter subgrid value based on text field by using WEB API DATA.

in fetch xml they use control.setParameter("fetXml",fetXml);

but in web api data set paramerter is not working,

How to set view for subgrid with custom fields value 

setCurrentView

*This post is locked for comments

  • Verified answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: Filter Subgrid based on field value without using fetchXml

    You can literally change what appears in the subgrid based on the values. All you have to do this provide a new query to the subgrid which will replace the out of the box query.

    it is mentioned in the above thread and also here : nishantrana.me/.../plugin-on-retrieve-multiple-in-crm-2015

    hachecrm2011.wordpress.com/.../filtering-views-by-intercepting-retrieve-multiple-queries-with-a-plugin

    simply check if(somefield = somevalue)

    {

    replace the query out of the box

    }

    else

    continue to show out of the box query.

  • Shadendra Profile Picture
    40 on at
    RE: Filter Subgrid based on field value without using fetchXml

    Okay. Is there any way to display subgrid value based on ID and NAME.

    or show custom value in sub grid.

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: Filter Subgrid based on field value without using fetchXml

    other way of doing this is to use the plugin on retrieve multiple message and should be a pre - operation plugin. this code above is not fully supported too.

    check here : community.dynamics.com/.../236817

  • Shadendra Profile Picture
    40 on at
    RE: Filter Subgrid based on field value without using fetchXml

    function OnChangeSubgrid() {

       var text = Xrm.Page.getAttribute("new_text").getValue()

       if (text != "") {

    //var SubGrid = document.getElementById("Grid");

     // var SubGrid = Xrm.Page.getControl("Grid").getGrid().getRows().get(0).getData().getEntity().getId();

    //var SubGrid =Xrm.Page.ui.controls.get("Grid");

      var SubGrid= window.parent.document.getElementById("Grid");

           if (SubGrid == null) {

               setTimeout(function () { OnChangeSubgrid(); }, 2000);

               return;

           }

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

         "<entity name='account'>" +

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

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

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

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

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

    "<filter type='and'>" +

               "<condition attribute='new_text' operator='eq' value='"+text+"' />" +

             "</filter>" +

         "</entity>" +

       "</fetch>";

           SubGrid.control.SetParameter("fetchXml",fetchXml);

           SubGrid.control.Refresh();

       }

    }

    this code is working fine But I want know another way of doing this without FETXML

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: Filter Subgrid based on field value without using fetchXml

    Hi There,

    If setParameter is not working - it can be due the fact that , it is not able to get your grid control fully.

    Would you mind posting the script and also did you try to debug the script to find out why and where it is failing - anything in the browser console?

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans