Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Subgrid FetchXML with JS code error

$
0
0

There are many posts and articles which suggest to use FetchXml with Java Script to refresh SubGrid with custom FetchXml. Below is code.

function dynamicallyFilterSubGrid() {

    var objSubGrid = window.parent.document.getElementById("PPP");
    
    if (objSubGrid == null || objSubGrid.readyState != "complete") {
        setTimeout(dynamicallyFilterSubGrid, 2000);
        return;
    }
    else {
    
        var category = Xrm.Page.getAttribute('Products').getValue();
    
        var FetchXml = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">' +
        '<entity name="product">' +
    '<attribute name="name" />' +
    '<attribute name="productnumber" />' +
    '<attribute name="description" />' +
    '<attribute name="statecode" />' +
    '<attribute name="productstructure" />' +
    '<order attribute="productnumber" descending="false" />' +
  '</entity>' +
'</fetch>' +
         objSubGrid.control.SetParameter("fetchXml", FetchXml);
        //Refresh grid to show filtered records only. 
        objSubGrid.control.Refresh();
    }
}

I m getting two issues, probably they are because of client side API is changed but neither I get an example which is working correctly or MSDN documentation say something about it.

Issues:

There are two errors in code:

1. objSubGrid.readyState != "complete" 

readyState remain undefiend and this condition never becomes true and because of 

        setTimeout(dynamicallyFilterSubGrid, 2000);


it keep looping and never execute next part. I tried to exclude this code to force next execution there was below issue. 

 


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

TypeError: Cannon read property 'SetParameter' of undefined

Kindly guide what are these API changes and if there is a valid example of this. Thanks for your help. 


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>