Hi,
I have been working on CRM 2013 on-premise. I am trying to apply dynamic filtration on a lookup field based on the value chosen in 3 other lookup fields.
All the fields are lookup fields and I am using a javascript to filter value of Test Sell Rate based on value entered in all the above fields. Test Sell rate entity has all the above entities present as lookup fields in it. I am applying my javascript on change event on field Test Level. I am using the following code:
src="ajax.googleapis.com/.../jquery.min.js"
function preFilterLookup() {
Xrm.Page.getControl("testsellrate").addPreSearch(function ()
{
addLookupFilter();
});
}
function addLookupFilter()
{
var rolecategory = Xrm.Page.getAttribute("testrolecategory").getValue();
var role = Xrm.Page.getAttribute("testrole").getValue();
var pricelist = Xrm.Page.getAttribute("testpricelist").getValue();
var level = Xrm.Page.getAttribute("testlevel").getValue();
if (level != null)
{
fetchXml = "<filter type='and'><condition attribute='testrolecategory' operator='eq' value='" + rolecategory + "' /><condition attribute='testrole' operator='eq' value='" + role + "' /><condition attribute='testlevel' operator='eq' value='" + level + "' /><condition attribute='testpricelist' operator='eq' value='" + pricelist + "' /></filter>";
Xrm.Page.getControl("testsellrate").addCustomFilter(fetchXml);
}
}
I am getting following error:
Microsoft Dynamics CRM Error Report Contents
<CrmScriptErrorReport>
<ReportVersion>1.0</ReportVersion>
<ScriptErrorDetails>
<Message>Unable to get property 'addPreSearch' of undefined or null reference</Message>
<Line>4</Line>
<URL>/%7B636623675690000145%7D/WebResources/new_filteredlookup</URL>
<PageURL>/main.aspx?etc=10018&extraqs=%3f_CreateFromId%3d%257bE4DD5965-2C23-E811-811F-003048D10ACE%257d%26_CreateFromType%3d3%26_gridType%3d10018%26etc%3d10018%26id%3d%257b8DCF0143-5348-E811-8121-003048D10ACE%257d%26rskey%3d%257bB15E6CA9-5B9E-4C74-881E-3577FE1F8BA1%257d&pagemode=iframe&pagetype=entityrecord&rskey=%7bB15E6CA9-5B9E-4C74-881E-3577FE1F8BA1%7d</PageURL>
<Function>anonymousr:Unabletogetproperty'addPreSearch'ofundefinedornullreference</Function>
<CallStack>
<Function>anonymousr:Unabletogetproperty'addPreSearch'ofundefinedornullreference</Function>
</CallStack>
</ScriptErrorDetails>
<ClientInformation>
<BrowserUserAgent>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134</BrowserUserAgent>
<BrowserLanguage>undefined</BrowserLanguage>
<SystemLanguage>undefined</SystemLanguage>
<UserLanguage>undefined</UserLanguage>
<ScreenResolution>1707x960</ScreenResolution>
<ClientName>Web</ClientName>
<ClientTime>2018-05-21T23:11:29</ClientTime>
</ClientInformation>
</CrmScriptErrorReport>
Is anyone else facing an issue like this?
*This post is locked for comments