aartishaw

Remove Duplicates from cascade lookup column

Blog Post created by aartishaw on Nov 3, 2016

Scenario: We have two lookup column . Column A contains Country and Column B contains Sites.

Based on country selection sites will get filter out .

Issue: Since Sites contains duplicates value , in drop-down also it get visible.

Solution: 1. In nintex form , save client id for the column B dropdown in nintex form. In below code client id is "txtsite".

Then using $("select[id="+txtsite+"]>option") we get all list of values in dropdown .

On "Mousedown" event , create array and check each value of dropdown , if value is already in array remove value otherwise add value to array. Once all check has been done, assign back the array to control value.

 

<script type="text/javascript">

//<![CDATA[

 

NWF$(document).ready(function(){

    NWF$("#"+txtsite).on('mousedown',function(){

var usednames={};

$("select[id="+txtsite+"]>option").each(function(){

if(usednames[this.text]){

                $(this).remove();

            }

            else{

                usednames[this.text]=this.value;

            }

 

 });

 

 });

});//]]>

</script>

<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>

Outcomes