Hello All,
I have created a script that triggers on clicking on the Lookup field so to show only filter the records as per requirements. we all know that to apply filter on the lookup field the First step is getting the lookup control, then setting the event(addPreSearch) and then pass the function as an action, for eg
1. Xrm.Page.getControl("nfs_project").addPreSearch(addFilter);
Second step we create the filter criteria inside the function and then again get the lookup control and set the filter using addCustomFilter for eg.
2.
function addFilter(){
var filter ="....";
Xrm.Page.getControl("nfs_project").addCustomFilter(filter);
}
-but in my scenario this is not working, what my requirement is i have added project lookup on my custom entity, i want only those projects shows which are of Template Type.
The project are of type template only when its field Is Template is True. so i have set the criteria according to it, I am sharing full code please view and help me to understand.
Full code
function preFilterLookup()
{
Xrm.Page.getControl("nfs_project").addPreSearch(addFilter);
}
function addFilter()
{
debugger;
var filter = "<filter type='and'>" +
"<condition attribute='msdyn_istemplate' operator='eq' uitype='msdyn_project' value='1' />" +
"</filter>";
Xrm.Page.getControl("nfs_project").addCustomFilter(filter);
}
Result