- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2025 06:13 AM
Hi,
I am trying to populate the results in list collector variable based on the value selected from another variable.
I have variable A (selectbox) and variable B(list collector). When I select any option from variable A for eg. "x1" then variable B referencing a customized table having a field u_description which will filter u_description contains "read" keyword and u_description contains "x1". Based on the condition, it will display the one or multiple results from the table in the varible B.
I am using a script include and client script for this requirement and it is not working. Can somebody help on this.
Script Include :
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2025 01:54 AM
you need to do 2 things which I mentioned in my 1st response to your question
1) advanced ref qualifier
a) why variable value will be random? You said it's a select box so it should have choices in it, you can use that.
You can use this, for x1 choice value you can have a query
javascript:var variableValue = current.variables.please_select_the_fileserver_where_the_shared_folder_is_located.toString() ; var query; if(variableValue == 'x1') query = 'u_descriptionLIKEread^u_descriptionLIKE' + variableValue; query;
If you want the same filter for other drop down choices then do this generic
javascript:var variableValue = current.variables.please_select_the_fileserver_where_the_shared_folder_is_located.toString() ; var query = 'u_descriptionLIKEread^u_descriptionLIKE' + variableValue; query;
2) variable attributes - add this
ref_qual_elements=please_select_the_fileserver_where_the_shared_folder_is_located
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2025 03:24 AM
please update : in your ref qualifier.
Community converts : to :
share the choices for your select box?
Also share if there are records matching in your table with that filter condition?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2025 09:30 AM
Hello @Koyel Guha
Please follow exact code that sent you.
1. Your encoded query is wrong. Why you have added "read" in between the query because it must be an input.
2. Please push sys_id in the array
3. Change the return statement as it should contain sys_id in the statement
4. Please confirm, Is your select box type variable referencing any table or there are some custom choices?
By using my script, it should work
Thank You!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2025 11:58 AM
Hi Rushi,
1 - We are referencing to a customised ad group table where we have queryname as ad group name and there is a description field where we have the read keyword and the server values from the selectbox variable.
When I select any option from variable A(selectbox) for eg. "x1" then variable B(list collector) with displaying the list of query names i.e ad group names which is referencing a customized table having a field u_description which will filter u_description contains "read" keyword and u_description contains "x1".
variable A = x1, then variable B should check the customised table's description field contains [ read keyword AND x1(selected from variable A) and displays the number of querynames from the table. If there is only one record it will show 1 , if multiple it will show multiple values containing both read keyword and x1 from variable A.
As the list collector variable B displays the query names field of the customised table. I am using u_query_name. Should i still use sys_id here ?
variable A select box is not referencing to any table , it is a choice field.
Let me know in case of any question and confirm where i need to correct.
Thanks for helping me on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2025 10:45 PM - edited ‎06-30-2025 10:48 PM
Hello @Koyel Guha
I have edited your code. Try the below code
var FilterActiveDirectory = Class.create();
FilterActiveDirectory.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getFilteredSysIds: function(inp) {
var input = inp;
var info = [];
var gr = new GlideRecord('u_active_directory_groups');
gr.addQuery('u_descriptionLIKE' + input + '^u_descriptionLIKE' + input); //if this is not working try below addquery
//gr.addQuery('u_descriptionLIKE' + input + '^ORu_descriptionLIKE' + input);
gr.query();
gs.info("Koyel17" + input);
while (gr.next()) {
gs.info("Koyel19" + gr.sys_id);
info.push(gr.getValue('sys_id').toString());
}
return 'sys_idIN' + info.join(",");
},
type: 'FilterActiveDirectory'
});
Reference Qualifier:
javascript: new global.FilterActiveDirectory().getFilteredSysIds(current.variables.please_select_the_fileserver_where_the_shared_folder_is_located);
Thank you!
Thank You!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2025 01:54 AM
Hi Rushi,
I have to use read keyword as well as it is considering read And value from variable A.
However, i have tried exactly what you have shared. but it is still showing all the values.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2025 11:03 PM
sorry you didn't share screenshots
the logic I shared should work fine.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
