I am filtering the Source Campaign lookup based on Optionset Originating Lead
Scenario 1: I am filtering if originating Lead is "Employee- Frank Hooper" then show all campaigns.
Scenario 2: for all other Originating Lead value it showed specific Campaigns.
Problem:- if using Scenario 1 it work fine and but when using scenario 2 after that go again on scenario 1 it stop working not any result in lookup.
I hope it well explained.
// Filter Source Campaign Lookup function preFilterLookup() { if(Xrm.Page.getAttribute("aaj_originatinglead").getText()=="Employee - Frank Hooper") { Xrm.Page.getControl("campaignid").addPreSearch(function () { frankHooperLookupFilter(); }); } else { Xrm.Page.getControl("campaignid").addPreSearch(function () { addLookupFilter(); }); } } function frankHooperLookupFilter() { fetchXml = "<filter type='and'><condition attribute='statecode' operator='eq' value='0'/></filter>"; Xrm.Page.getControl("campaignid").addCustomFilter(fetchXml); } function addLookupFilter() { var originatingLead = Xrm.Page.getAttribute("aaj_originatinglead").getValue(); if (originatingLead != null) { fetchXml = "<filter type='and'><condition attribute='aaj_originatinglead' operator='eq' value='" + originatingLead + "' /></filter>"; Xrm.Page.getControl("campaignid").addCustomFilter(fetchXml); } }