I have set up the Regarding lookup (in Email entity) to show only Incidents and a custom entity, called Problem.
I can set up through JavaScript a custom view (filtered) only for one of these entities, but not for both.
How can I have multiple custom views for this lookup?
document.getElementById("regardingobjectid").setAttribute("defaulttype", "112"); document.getElementById("regardingobjectid").setAttribute("lookuptypenames", "Incident:112:Case,aux_problem:10036:Problem"); document.getElementById("regardingobjectid").setAttribute("lookuptypes", "112,10036"); document.getElementById("regardingobjectid").setAttribute("lookuptypeIcons", "/_imgs/ico_18_112.gif:../WebResources/aux_problem_icon_16"); setCasesView("aux_account", "regardingobjectid", false);
I call here to setProblemsView, the same as setCasesView but not setting it as default (with the false at the end)
Xrm.Page.getControl(lookupFieldName).addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, false);
But is not applying my filtered view when I choose problems Problems
function setCasesView(entityFieldName, lookupFieldName, resetSelection) { // use randomly generated GUID Id for the view var viewId = "{xxxxxxxx-xxxx-0000-9FB6-58E69E4C81AA}"; var entityName = "incident"; // give the custom view a name var viewDisplayName = "Cases in Account: " + accname + ""; // find all cases where account is the account selected var fetchXml = ... var layoutXml = ... Xrm.Page.getControl(lookupFieldName).addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true); document.getElementById(lookupFieldName).setAttribute("disableViewPicker", "1"); }