Monday, September 19, 2016

Filter lookup based on another lookup - Microsoft Dynamics CRM

Based on one lookup:

Right click on field and go to change properties.
Select the checkbox and select the drop down in "Related Records Filtering" Section

Based on two lookup:

Call the function onchange of second lookup and onload of form.

It will add filter for third lookup.

Lookup1: ccs_category

Javascript Function:

function filterSubtype() {
    // add the event handler for PreSearch Event

function subtype_addFilter() {
   //find contact contains this
var categoryId = Xrm.Page.getAttribute("category").getValue() != null ? Xrm.Page.getAttribute("category").getValue()[0].id : null;
   var caseTypeId = Xrm.Page.getAttribute("casetype").getValue() != null ? Xrm.Page.getAttribute("casetype").getValue()[0].id : null;  

    //create a filter xml
   var filter = "<filter type='and'><condition attribute='category' operator='eq' value='" + categoryId + "' /><condition attribute='casetype' operator='eq' value='" + caseTypeId + "' /></filter>";

    //add filter

No comments:

Post a Comment