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

Products from Orders on Account form against relative customer.

$
0
0

This my code

function dynamicallyFilterSubGrid()
{
debugger;
//RelatedCars : is name of subgrid given on Form.
//var objSubGrid = document.getElementById("OrderProduct");
var objSubGrid = Xrm.Page.getControl("OrderProduct");
//var objSubGrid = window.parent.document.getElementById("OrderProduct");
var currentleadId = Xrm.Page.data.entity.getId();;
//CRM loads subgrid after form is loaded.. so when we are adding script on form load.. need to wait unitil subgrid is loaded.
// thats why adding delay..
if (objSubGrid == null)
{
setTimeout(dynamicallyFilterSubGrid, 2000);
return;
}
else
{
//when subgrid is loaded, get category value
//var category = Xrm.Page.getAttribute('account').getValue();

//Create FetchXML for sub grid to filter records based on category

var FetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='salesorderdetail'>" +
"<attribute name='productid' />" +
"<attribute name='priceperunit' />" +
"<attribute name='quantity' />" +
"<attribute name='salesorderdetailid' />" +
"<attribute name='manualdiscountamount' />" +
"<order attribute='productid' descending='false' />"
"<link-entity name='salesorder' from='salesorderid' to='salesorderid' alias='ag'>"+
"<link-entity name='account' from='accountid' to='customerid' alias='ah' />"+
"</link-entity>"+
"</entity>" +
"</fetch>";

// Layout of subgrid.
var LayoutXml = "<grid name='OrderProduct' object='8' jump='new_name' select='1' preview='1' icon='1'>" +
" <row name='result' id='new_boat'>" +
"<cell name='productid' width='100' />" +
"<cell name='priceperunit' width='200' />" +
"<cell name='quantity' width='200' />" +
"<cell name='manualdiscountamount' width='100' />" +
"<cell name='extendedamount' width='100' />" +
"</row>" +
"</grid>";

//apply layout and filtered fetchXML
objSubGrid.control.SetParameter('layoutXml', LayoutXml); At this line me code gives an exception
//Xrm.Page.getControl("OrderProduct").SetParameter("layoutXml", LayoutXml);
objSubGrid.control.SetParameter('fetchXml', FetchXml); Or At this line me code gives an exceptioa
//Xrm.Page.getControl("OrderProduct").control.SetParameter("fetchXml", FetchXml);

//Refresh grid to show filtered records only.
//objSubGrid.control.Refresh();
Xrm.Page.getControl("OrderProduct").refresh();
}
}

This my error

One of the scripts for this record has caused an error. For more details, download the log file.
TypeError: Cannot read property 'SetParameter' of undefined at dynamicallyFilterSubGrid (win-bd86268lvbk/.../new_AXP)

I need help.?

Is this right approach?

What can I do to fulfill my requirement?

 


Viewing all articles
Browse latest Browse all 46379

Trending Articles



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