How to bind subgrid record dynamically based on the form Lookup value changes


All replies

  • Hi

    To bind subgrid based on lookup change you can write fetchxml query in javascript.


        var grid = document.getElementById('subgridname');
        if (grid == null) {
            setTimeout('updateSubGrid()', 2000);
        else {

            var lookupfield = new Array;

            lookupfield = Xrm.Page.getAttribute("lookupid").getValue();

            if (lookupfield != null) {

                var lookupid = lookupfield[0].id;
            else {
            var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
            fetchXml += "<entity name='entityname'>";
            fetchXml += "<attribute name='anyselected' />";       
            fetchXml += "<filter type='and'>";
            fetchXml += "<condition attribute='filterid' operator='eq' value='" + lookupid + "' />";
            fetchXml += "</filter>";  
            fetchXml += "</entity>";
            fetchXml += "</fetch>";

            grid.control.setParameter("fetchXml", fetchXml);      



    Suresh Sorde

    • Proposed as answer by Suresh Sorde Friday, September 20, 2013 12:47 PM
    Friday, September 20, 2013 9:35 AM
  • Thank you Suresh,

    I tried your source code,It is working for me.

    While trying I got an error, "Object doesn't support property or method 'setParameter'".

    After some search I findout the answar that, "setParameter" propert does not supported by IE7. So we have to replace and use the "SetParameter" instead of "setParameter.

    The different is "S".

    Thank you,

    Vimal Karthick

    Friday, September 20, 2013 12:32 PM
  • Hi Karthick

     thanks for the information.

    Dont forget to mark as answer :).

    suresh sorde

    Friday, September 20, 2013 12:49 PM