Hi,
I have order entity which contains field Unit(m, kg etc.). I have sub grid for the products and when an existing product is chosen to be added to the sub grid in-line input field appears where the user input can write some string and a drop down with suggested products that match this string show. 
Every product has unit by which it is measured. I want to filter the suggested products by the value from the field "Unit" in the Order entity. In the example from the picture I have chosen kg, so in the drop down only product measured with kg must appear(only these that appear in blue).
I have made JS web resource:
var unit = getValue("prista_unit");
var unitId = unit[0].id;
console.log(unitId);
//Create FetchXML for sub grid to filter records based on category
var fetchXml ="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>" +
"<entity name='pricelevel'>" +
"<attribute name='name' />" +
"<attribute name='transactioncurrencyid' />" +
"<attribute name='enddate' />" +
"<attribute name='egindate' />" +
"<attribute name='statecode' />" +
"<attribute name='pricelevelid' />" +
"<order attribute='name' descending='false' />" +
"<link-entity name='productpricelevel' from='pricelevelid' to='pricelevelid' alias='aa'>" +
"<filter type='and'>" +
"<condition attribute='uomid' operator='eq' value=' + unitId + '/>" +
"</filter>" +
"</link-entity>" +
"</entity>" +
"</fetch>";
console.log(Xrm.Page.getControl("Dialog_lookup_salesorderdetailsGrid_i_IMenu"));
Xrm.Page.getControl("Dialog_lookup_salesorderdetailsGrid_i_IMenu").addCustomFilter(fetchXML);
objSubGrid.control.Refresh();
The problem is that Xrm.Page.getControl can't reach the drop down. i think it is because the web resource is OnLoad and the drop down with suggestions appears after the user chooses to add Existing product. I have two questions:
1. I am not sure that I refer to the right control id. I inspected the element using chrome, but still not sure that is the right element id. Is there a certain way to find the id of the element using the solution menu?
2. How can I filter the drop down using JS web resource?
This is on CRM 2015.