Hey Mohd, thanks for the reply! I clicked on that link but unfortunately it seems to be focused on getting a custom filter applied to what options you see for a lookup. I'm needing something similar to this but for a subgrid. I found a few possible solutions out there but I'm having trouble getting them to work. Here's what I pieced together so far, it's set as an onLoad for the form and does not run into any errors. Unfortunately, it also doesn't seem to do anything... Any ideas?
For reference:
Current Entity: Contact
parentcustomerid = account name field in Contact
Subgrid Entity: Order Product Information
pll_customer = account name field in custom "Order Product Information" entity
Subgrid Name: Licensing
JS:
function Subgrid_setFilteredView(){
var subgrid = window.parent.document.getElementById("Licensing");
var lookupField = new Array;
lookupField = Xrm.Page.getAttribute("parentcustomerid").getValue();
if (lookupField != null) {
var accountName = lookupField[0].name;
var accountId = lookupField[0].id;
var fetchXml;
}
else {
return;
}
if(subgrid == null || subgrid.readyState != "complete"){
setTimeout(Subgrid_setFilteredView, 2000);
return;
}
fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
" <entity name='pll_orderproductinformation'>" +
" <attribute name='pll_product' />" +
" <attribute name='modifiedon' />" +
" <attribute name='pll_maintenancestart' />" +
" <attribute name='pll_maintenancelevel' />" +
" <attribute name='pll_maintenanceend' />" +
" <attribute name='createdon' />" +
" <attribute name='createdby' />" +
" <attribute name='pll_customer' />" +
" <attribute name='pll_orderproductinformationid' />" +
" <order attribute='pll_ordername' descending='false' />" +
" <filter type='and'>" +
" <condition attribute='pll_customer' operator='eq' uiname='" + accountName + "' uitype='account' value='" + accountId + "' />" +
" <condition attribute='pll_maintenanceend' operator='next-x-years' value='100' />" +
" </filter>" +
" </entity>" +
"</fetch>";
if (subgrid.control != null) {
subgrid.control.SetParameter("fetchXml", fetchXml);
subgrid.control.refresh();
}
else {
setTimeout(updateSubGrid, 2000);
}
}