Need a Simple OnChange Client Script to Force List Collector to Run/Refresh

kshaw
Giga Guru

I have a catalog item (hr request) that includes a List Collector.

I have a reference qualifier running correctly to filter that list based on the department. I am also hiding the filter section based on the attribute "no_filter". Everything is working fine.

However if the user/agent changes the department, the list collector does not update.

I am looking for an onChange client script that would force the list collector to refresh when the department is changed/

Thanks in advance for help

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

Hey,

You don't need a script, just update the variable to watch the element(s) you're wanting to use in the reference qual. There is a (poorly) documented attribute 'ref_qual_elements' that you use.

1. The variable on the form I want to include in the reference qual.

2. The variable name to watch (if you're using multiple, separate with ;)

find_real_file.png

find_real_file.png

View solution in original post

6 REPLIES 6

Jim Coyne
Kilo Patron

Here's an article from ServiceNow Guru from a few years ago that I believe still works - Changing the Filter of a List Collector Variable via Client Script.

I had found that too... too complicated for just a refresh.

Kieran's answer was bang on.

Yeah, that was the only way we could do it way back when before the attribute was added.  I fell into the trap of answering your actual question asking for a Client Script instead of giving a proper solution.  I usually shout out "why?" when I see others do that - I guess it had been a long week.  ????

Community Alums
Not applicable

We have been using the solution referenced on the ServiceNow Guru site quite successfully for a while.

However we recently came across a problem.

Our implementation of the Catalog Client Script works in Service Portal, but does not work in the Standard UI.

We were using the script changing only the variable name and the filter string. Of course, we may be doing something wrong.

I am a little curious as to whether and how these statement may now be behaving differently in the Standard UI:

        //Reset the filter query
        window[collectorName + 'g_filter'].reset();
        window[collectorName + 'g_filter'].setQuery(filterString);
        window[collectorName + 'acRequest'](null);

In any event, we found this article and the solution works for us in both Service Portal and Standard UI.

Thanks All for posting the question, the answer, and the useful comments!