Flitered Sub-grid in Online CRM 2015 RRS feed

  • Question

  • Hi all ,

       I have the following requirement. In Case form we included multiple sub-grids (Opportunity,Lead, etc..). On selecting the value in customer field, only the related records of that particular Customer should flow in the respective sub-grids.

    The same functionality we worked in CRM 2013 which was working fine. At present in CRM 2015 on loading the form some times it is working & some times it is not working (means some times it shows related record & some times it shows all records). Unable to identify the issue. We have also tried by refreshing the sub-grid twice in J-script.

    Any solution?

    Thanks &  Regards


    Monday, April 13, 2015 5:57 AM

All replies

  • Hi,

    You can use the below code. I also share it in my blog  Filter SubGrid

    function FilterSubgrid() {
     var Subgrid = document.getElementById("yoursubgridid");
     if (Subgrid== null) {
     setTimeout(function () { FilterSubgrid(); }, 2000);
    //if the grid hasn’t loaded run this again when it has
    var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
     +"<entity name='entityname'>"
     +"<attribute name='attributename1' />"
     +"<attribute name='attributename2'/>"
     +"<order attribute='orderattribute' descending='false' />"
     +"<filter type='filtertype'>"
     +"<condition attribute='conditionattributename' operator='operator' />"
    + "</fetch>";
    Subgrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid  
    Subgrid.control.Refresh(); //refresh the sub grid using the new fetch xml

    If you find this post helpful then please Vote as Helpful and Mark As Answer. Thanks and Regards, Polat Aydın My blog

    Monday, April 13, 2015 8:48 AM
  • Hi Polat,

     Thanks for your reply. We have done the same work. Please find below Jscript we have used, which is working fine in CRM 2013. In CRM 2015 some times it works & some times it shows all the records with out filter. So any other solution for this issue.

    function BindGridSubscription() {
        // Get  Customer
        var lookupfield = new Array;
        lookupfield = Xrm.Page.getAttribute("customerid").getValue();

        if (lookupfield != null) {
            var lookupid = lookupfield[0].id;
        else {

        var relatedSubscriptions = null;
        relatedSubscriptions = document.getElementById('sgvSubscriptionDetails');

        if (relatedSubscriptions == null || relatedSubscriptions.readyState != "complete") {
            setTimeout('BindGridSubscription()', 2000);

        var fetchXmlSubs = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
        fetchXmlSubs += "<entity name='opportunity'>";
        fetchXmlSubs += "<attribute name='opportunityid' />";
        fetchXmlSubs += "<attribute name='tec_zone' />";
        fetchXmlSubs += "<attribute name='totalamount' />";
        fetchXmlSubs += "<attribute name='tec_subscriptiontype' />";
        fetchXmlSubs += "<attribute name='tec_copystartdate' />";
        fetchXmlSubs += "<attribute name='tec_copyenddate' />";
        fetchXmlSubs += "<attribute name='tec_subscribedscheme' />";
        fetchXmlSubs += "<attribute name='tec_subscribedproduct' />";
        fetchXmlSubs += "<attribute name='tec_schemestartdate' />";
        fetchXmlSubs += "<attribute name='tec_schemeenddate' />";
        fetchXmlSubs += "<attribute name='tec_poimplementationdate' />";
        fetchXmlSubs += "<attribute name='tec_bookingformnumber' />";
        fetchXmlSubs += "<attribute name='tec_bookingdate' />";
        fetchXmlSubs += "<order attribute='tec_zone' descending='false' />";
        fetchXmlSubs += "<filter type='and'>";
        fetchXmlSubs += "<condition attribute='customerid' operator='eq' uitype='contact' value='" + lookupid + "' />";
        fetchXmlSubs += "</filter>";
        fetchXmlSubs += "</entity>";
        fetchXmlSubs += "</fetch>";

        relatedSubscriptions.control.SetParameter("fetchXML", fetchXmlSubs);




    Monday, April 13, 2015 10:21 AM
  • Hi Shankar,

    The solution is:

    1. Create function separately for refreshing all grids as mentioned below.

    2. Call above said function with time interval [ex:  setTimeout('GridRefresh()', 2000);], below the fetchXML on last of all the functions.

    function GridRefresh() {



    .... // all grids refresh


    If you find this post helpful then please Vote as Helpful and Mark As Answer.

    Thanks & Regards

    Samuel A

    Wednesday, April 22, 2015 9:52 AM