web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
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

I have the same question (0)
  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    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?

  • Shadendra Profile Picture
    40 on at

    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

    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

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

    or show custom value in sub grid.

  • Verified answer
    Rawish Kumar Profile Picture
    13,758 on at

    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.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans