Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

List collector

AbhishekCTS
Tera Contributor

I have a query in catalog item which is having 2 list collector variable type, and it is referencing to question_choice where it is having same set of choices for the 2 variables.

As per my requirement whenever i choose the choices from variable 1 like Paste and Copy as choices listed in it , the same choices should be excluded from the variable 2 and same goes vice-versa.

Please help me how i can achieve it 

 

9 REPLIES 9

@AbhishekCTS 

add only in 2nd variable as you want to add filter on 2nd

Also add in variable attributes what I mentioned

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

I tried it but it is not working , as per requirement if variable 1 choices are selected then variable 2 choices list should be exclude the choices which are selected in variable 1 and the vice versa also.

Attached screen shot for reference 

@AbhishekCTS 

community post adds : when I post colon i.e. :

So please use this colon

:

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

Tried the same as per your suggestion but still i cannot see the choices in variable 2 .

Hi @Ankur Bawiskar ,

 Thanks for you quick assistance but i found the solution by myself. I created a client callable script include and paste it is reference qualifier.

in both the variables Reference qualifier : 

javascript: new ScriptInclude().getFilter('16bbb52d3b3ecb5001afae8a04e45a7b', current.variables.variable2); 

along with variable attributes as given by you .

script include function : 

getFilter: function(questionSysId, selectedValues) {
        if (!questionSysId || questionSysId.toString().trim() === '') {
            return 'sys_id=NULL';
        }
        var query = 'question=' + questionSysId;
        if (selectedValues && selectedValues.toString().trim() !== '') {
            var choiceValues = [];
            var gr = new GlideRecord('question_choice');
            gr.addQuery('sys_id', 'IN', selectedValues.toString());
            gr.query();
            while (gr.next()) {
                choiceValues.push(gr.getValue('value'));
            }
            if (choiceValues.length > 0) {



                query += '^valueNOT IN' + choiceValues.join(',');

            }
        }
        return query;
    },