Removing duplicates in List Collector

naresh831
Tera Contributor

How can we remove the duplicate values in List collector Type in Service catalog ? Tried using "Unique values only". But it's not working.

Did anybody handled the duplicates in List Collector ?

Thanks

Ram

2 REPLIES 2

sachin_namjoshi
Kilo Patron
Kilo Patron

I had the same requirement so added below workaround:


1) Added client callable script include which will return sys_ids (process your record list and just copy sys_ids that you want to show on the list)


2) Added catalog client script for onload item.


3) Within same catalog client script pulled sys_ids using glide ajax call and used it in the filter.



Eg:


function onChange() {


        var ga = new GlideAjax('ClientCallableScriptName');


        ga.addParam('sysparm_name','method_name');


        ga.getXMLWait();


        var sysIDList = ga.getAnswer();


      //Apply a default filter to the list collector variable




    var collectorName = 'list_collector_name';


    var filterString = 'sys_idIN'+sysIDList;


//Hide the list collector until we've set the filter


    g_form.setDisplay(collectorName, false);


    setCollectorFilter();


 


    function setCollectorFilter(){


          //Test if the g_filter property is defined on our list collector.


          //If it hasn't rendered yet, wait 100ms and try again.


          if (eval('typeof(' + collectorName + 'g_filter)') == 'undefined' ) {


                setTimeout(setCollectorFilter, 100);


                return;


          }


          //Find the filter elements


          var fil = gel('ep');


          //Hide the filter elements by un-commenting the following lines


          /*fil.rows[0].style.display = 'none';


          fil.rows[1].style.display = 'none';


          fil.nextSibling.rows[0].style.display = 'none'; //Filter description text*/


       


          //Reset the filter query


          eval(collectorName + 'g_filter.reset()');


          eval(collectorName + 'g_filter.setQuery("' + filterString + '")');


          eval(collectorName + 'acRequest(null)');


          //Redisplay the list collector variable


          g_form.setDisplay(collectorName, true);


    }


}



See if it helps.



Thanks,


Sachin.


milapshah15
Kilo Expert

Hi Naresh,



You have a data issues here and as list collector works on the references , you have to clean your source table to remove the duplicates.



Warm regards,
Milap