Hi all,
I created a JS-based custom XML-filter to filter only certain types of accounts in a lookup field on the opportunity form. I call this function during the onload() of the page. It is meant to only show certain type of accounts where the name of the account contains value ABC.
function FilterOnLoad()
{
addEventHandler();
}
function addEventHandler() {
// add the event handler for PreSearch Event
Xrm.Page.getControl("CUSTOMLOOKUPFIELD").addPreSearch(addFilter);
}
function addFilter() {
//find account names that contain ABC
var companyname = "%ABC%";
//create a typical xml filter
var filter = "<filter type='and'>" +
"<condition attribute='name' operator='like' value='" + companyname+ "'/>" +
"</filter>";
//add filter
Xrm.Page.getControl("CUSTOMLOOKUPFIELD").addCustomFilter(filter);
}
However, I show / hide CUSTOMLOOKUPFIELD based on business rules (conditional show) and I run into two errors:
- The business rule does not work when the script is loaded
- There is an error when exiting the page:
Microsoft Dynamics CRM Error Report Contents
<CrmScriptErrorReport>
<ReportVersion>1.0</ReportVersion>
<ScriptErrorDetails>
<Message>bpf_c113247d7ac901666d8a212e13167cac is undefined</Message>
<Line>7</Line>
<URL></URL>
<PageURL>/main.aspx?etc=3&extraqs=%3fetc%3d3%26id%3d%257b9709F3ED-C898-E511-80BD-00155D64CA37%257d&pagemode=iframe&pagetype=entityrecord</PageURL>
<Function>anonymouseError:bpf_c113247d7ac901666d8a212e13167cacisundefined</Function>
<FunctionRaw>ReferenceError: bpf_c113247d7ac901666d8a212e13167cac is undefined</FunctionRaw>
<CallStack>
<Function>anonymouseError:bpf_c113247d7ac901666d8a212e13167cacisundefined</Function>
</CallStack>
</ScriptErrorDetails>
<ClientInformation>
<BrowserUserAgent>Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.3)</BrowserUserAgent>
<BrowserLanguage>nl-NL</BrowserLanguage>
<SystemLanguage>en-US</SystemLanguage>
<UserLanguage>nl-NL</UserLanguage>
<ScreenResolution>1920x1080</ScreenResolution>
<ClientName>Web</ClientName>
<ClienState>Online</ClienState>
<ClientTime>2015-12-02T08:47:40</ClientTime>
</ClientInformation>
<ServerInformation>
<OrgLanguage>1033</OrgLanguage>
<OrgCulture>1043</OrgCulture>
<UserLanguage>1033</UserLanguage>
<UserCulture>1043</UserCulture>
<OrgID>X</OrgID>
<UserID>X</UserID>
<CRMVersion>7.0.0.3543</CRMVersion>
</ServerInformation>
</CrmScriptErrorReport>
Does anyone know how to solve this issue?