Below is my code :
function filterQuoteGridForAccountid2()
{
//Get Subgrid control
var quoteSubGrid = window.parent.document.getElementById("CustomOrderRequestGrid2");
if (quoteSubGrid == null) {// || quoteSubGrid1.readyState != "complete"
setTimeout(filterQuoteGridForAccountid2, 2000);
return;
}
else {
var accountID2= null;
if (Xrm.Page.getAttribute("dsl_searchaccountlookup").getValue() != null)
{
accountID2 = Xrm.Page.getAttribute("dsl_searchaccountlookup").getValue()[0].id.replace("}", "").replace("{", "");
var fetchXml = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">'
+'<entity name="quotedetail">'
+'<attribute name="productid" />'
+'<attribute name="quotedetailid" />'
+'<attribute name="dsl_accountsid" />'
+'<order attribute="productid" descending="false" />'
+'<link-entity name="account" from="accountid" to="dsl_accountsid" visible="false" link-type="outer" alias="adc">'
+'<attribute name="dsl_accountid" />'
+'</link-entity>'
+'<link-entity name="quote" from="quoteid" to="quoteid" visible="false" link-type="inner" alias="ad">'
+'<attribute name="dsl_contact" />'
+'<attribute name="dsl_accountid" />'
+'<attribute name="dsl_companyid" />'
+'<attribute name="customerid" />'
+'<filter type="and">'
+'<condition attribute="dsl_accountid" operator="eq" uitype="account" value="' + accountID2 + '" />'
+'</filter>'
+'</link-entity>'
+'</entity>'
+'</fetch>';
if(quoteSubGrid.control != null)
{
quoteSubGrid.control.SetParameter("fetchXml", fetchXml);
//Refresh grid to show filtered records only.
quoteSubGrid.control.Refresh();
}
else
{
setTimeout(filterQuoteGridForAccountid2, 2000);
}
}
}
}