Hi Rohit,
First get all the consultant on on change of account lookup in custom entity using below code, keep it on change of account
***********************************
var consultant1;
var consultant2;
function getAllConsultant() {
var accountid = Xrm.Page.getAttribute("accountlookupschemaname").getValue()[0].id;
var consultantFetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
" <entity name='account'>"+
" <attribute name='consultant1' />"+
" <attribute name='consultant2' />"+
" <attribute name='consultant3' />"+
" <attribute name='consultant4' />"+
" <attribute name='consultant5' />"+
" <filter type='and'>"+
" <condition attribute='accountid' operator='eq' value="+accountid+" />"+
" </filter>"+
" </entity>"+
"</fetch>";
var ConsultantRecords = XrmServiceToolkit.Soap.Fetch(consultantFetchXML);
if (ConsultantRecords.length > 0) {
if (ConsultantRecords[0].attributes.consultant1 != undefined)
consultant1 = ConsultantRecords[0].attributes.consultant1;
}
if (ConsultantRecords[0].attributes.consultant2 != undefined)
consultant2 = ConsultantRecords[0].attributes.consultant2;
}
preFilterlookup ();
}
*********************************
get all the consultant id and pass it in below function addLookupFilter,
Note : call preFilterlookup in above code when you get all the consultant value.
**************************************************
function preFilterLookup() {
Xrm.Page.getControl("contactlookup").addPreSearch(function () {
addLookupFilter();
});
}
function addLookupFilter() {
if (email != null) {
fetchXml = "<filter type='and'><condition attribute='contactid' operator='eq' value='" + consultant1 + "' /><condition attribute='contactid' operator='eq' value='" + consultant2 + "' /></filter>";
Xrm.Page.getControl("contactlookup").addCustomFilter(fetchXml);
}
}
**************************************************
I have not tested it, Please debug the code and test it at your end.
Hope this helps.
Best Regards,
Shahbaaz