I have three lookup's. I have to filter the third lookup based on the above two lookuups data it is working fine.
but if i delete data of second lookup then i have to filter the records based on the first lookup.
Now when first i filter the third lookup based on double lookup filter its working fine but if i am deleting on of the lookup and i am trying to filtering the single lookup filter it is showing Invalid Argument.
plz help me to find out the solution
*This post is locked for comments
but what if i need to pass an argument to my presearch, i can't doing it like this Xrm.Page.getControl("new_casetype").addPreSearch(addFilter(param));,, i only can doing it like this Xrm.Page.getControl("new_casetype").addPreSearch(function() { addFilter(param) }); , how can i remove my presearch
Hi Yadnyesh,
now it is working fine thanks for reply and also ur suggestion is solved my issue
Hi,
When you are using this statement,
Xrm.Page.getControl("new_casetype").addPreSearch(function() { addFilter() });
You are binding anonymous function and hence you are unable to remove it.
Try below:
Xrm.Page.getControl("new_casetype").addPreSearch(addFilter);
Xrm.Page.getControl("new_casetype").removePreSearch(addFilter);
Hi,
Thanks for reply
but see my code in that i applied for removepresearch filter in single lookup filter function that is not working.
once i am selecting doublelookup and again i am trying to select single lookup filter at that time it is showing Invalid argument
Hi,
You cannot delete the custom filter once added. You will have to remove the presearch event handler and re register the same.
Refer below:
sorry for late reply
here my code is
function oncategory_change(){
debugger;
if(Xrm.Page.getAttribute("new_category").getValue() == null){
Xrm.Page.getAttribute("new_casetype").setValue();
casetype_onload();
Xrm.Page.getAttribute("new_casesubtype").setValue(null);
}
else
{
casetype_onchange_filter();
}
}
////////Double Lookup Filter
function casetype_onchange() {
debugger;
// add the event handler for PreSearch Event
Xrm.Page.getControl("new_casetype").addPreSearch(function() { addFilter() });
}
function addFilter() {
var categoryIdn = Xrm.Page.getAttribute("new_category").getValue() != null ? Xrm.Page.getAttribute("new_category").getValue()[0].id : null;
var oemId = Xrm.Page.getAttribute("new_oem").getValue() != null ? Xrm.Page.getAttribute("new_oem").getValue()[0].id : null;
//var categoryIdn = categoryId.toUpperCase();
ar filter = "<filter type='and'><condition attribute='new_category' operator='eq' value='" + categoryIdn + "' /><condition attribute='new_oem' operator='eq' value='" + oemId + "' /></filter>";
Xrm.Page.getControl("new_casetype").addCustomFilter(filter);
}
/////////single Lookup Filter
function casetype_onload(){
debugger;
Xrm.Page.getControl("new_casetype").removePreSearch(function() { addFilter() });
Xrm.Page.getControl("new_casetype").addPreSearch(function() { Filtercasetype() });
}
function Filtercasetype(){
Xrm.Page.getControl("new_casetype").removePreSearch(function() { addFilter() });
var oemId = Xrm.Page.getAttribute("new_oem").getValue() != null ? Xrm.Page.getAttribute("new_oem").getValue()[0].id : null;
var fetch = "<filter type='and'><condition attribute='new_oem' value='"+oemId +"' operator='eq'/></filter>";
Xrm.Page.getControl("new_casetype").addCustomFilter(fetch);
}
You'll need to post your code, otherwise we can only guess as to what's wrong.
André Arnaud de Cal...
292,031
Super User 2025 Season 1
Martin Dráb
230,868
Most Valuable Professional
nmaenpaa
101,156