Hi everyone,
I am trying to apply a custom filter to a contact lookup based on a related entity. I am using the addPreSearch and addCustomFilter functions and from what i have seen in various forum it looks like it should be working but whenever i try to test it an error occurs in the console.
There error in the console:
"Uncaught TypeError: $v_5 is not a function
at global.ashx?ver=1149864775:4020
at Mscrm.TurboForm.Control.ViewModel.LookupViewModel.$DW_5 (JsProvider.ashx?bundle=FormControlBundle&ids=1223231347-405283869:21718)
at Mscrm.TurboForm.Control.ViewModel.LookupViewModel.issueLookupSearch (JsProvider.ashx?bundle=FormControlBundle&ids=1223231347-405283869:21723)
at Mscrm.TurboForm.Control.View.LookupEditElement.showSearchResults (JsProvider.ashx?bundle=FormControlBundle&ids=1223231347-405283869:28514)
at Mscrm.TurboForm.Control.View.LookupEditElement.$Il_2 (JsProvider.ashx?bundle=FormControlBundle&ids=1223231347-405283869:29224)
at HTMLInputElement.<anonymous> (MicrosoftAjax.js?ver=1149864775:24)
at HTMLInputElement.b (MicrosoftAjax.js?ver=1149864775:2922)"
The main parts of the code:
function PreFilter() {
if (Xrm.Page.getAttribute("fieldname").getValue() != null)
{
Xrm.Page.getControl("fieldname").addPreSearch(addLookupFilter());
}
}
...after getting the id's required for the filter:
var fetchXml = "<filter type='and'>"; fetchXml = fetchXml + "<condition attribute='contactid' operator='in'>"; for (var j = 0; j < tenants.length; j++) { fetchXml = fetchXml + "<value>{" + tenants[j]["id"].toUpperCase() + "}</value>"; } fetchXml = fetchXml + "</condition>"; fetchXml = fetchXml + "</filter>"; Xrm.Page.getControl("field").addCustomFilter(fetchXml, "contact");
I have used alerts in the script to see where it gets to and what the fetchXml looks like and it all seemed okay to me, this is an example of what its returned:
<filter type='and'>
<condition attribute='contactid' operator='in'>
<value>{1300A5B9-83FD-E311-80C1-0050568F0035}</value>
<value>{8500A5B9-83FD-E311-80C1-0050568F0035}</value>
</condition>
</filter>
If anyone could tell me why i am getting this error, it would be greatly appreciated.
*This post is locked for comments