Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Custom Filter Lookup Issue - Dynamics 365

$
0
0

Hi techies,

We are facing an issue with CustomFilterLookup in Dynamics 365. We have to filter contacts based on the account selected.

We have written a javscript and calling the Javascript onLoad and OnChange.

When we select account then it filters contacts for the first time. On change of value next time , It shows no contacts though there are some contacts.

below is the javascript for the reference.

function OnChangeDistributor() {
   debugger;
   var distributorAttr = Xrm.Page.getAttribute("tvsc_distributorid");
   var rmAttr = Xrm.Page.getAttribute("tvsc_rmid");
   if (distributorAttr && rmAttr) {
       //if (!isOnLoad)
       //    rmAttr.setValue(null);
       if (distributorAttr.getValue()) {
           var distributorId = distributorAttr.getValue()[0].id.replace(/\{|\}/gi, '');

           Xrm.Page.getControl("tvsc_rmid").removePreSearch(function () {
               AddLookupForContact(distributorId);
           });


           Xrm.Page.getControl("tvsc_rmid").addPreSearch(function () {
               AddLookupForContact(distributorId);
           });


       }
       else {
           rmAttr.setValue(null);
       }
   }
}

function AddLookupForContact(distributorId) {

               var fetchXml;
               fetchXml = "<filter type='and'>" +"      <condition attribute='parentcustomerid' operator='eq' value='" + distributorId + "' />" +"    </filter>";

               Xrm.Page.getControl("tvsc_rmid").addCustomFilter(fetchXml);
           }


Any help is appreciated.

Thanks in Advance


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images