- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 10:14 PM
We are currently creating two variables (a select box variable and a list collector variable) in the catalog item.
As an example, we have created choices A, B, C, D, and E for the select box variable and choices 1, 2, 3, 4, and 5 for the list collector.
【Set values for the list collector】
List table: Question Choice[question_choice].
Reference qualifier: sys_created_onON2024-12-25@javascript:gs.dateGenerate('2024-12-25','start')@javascript:gs.dateGenerate('2024-12 -25','end')
【Question】
I would like the list collector variable to show 1, 2, and 3 (4 and 5 are hidden) when A, B, and C are selected in the select box variable, while 4 and 5 are shown (1, 2, and 3 are hidden) when D and E are selected.
This is indicated in the image diagram.
Can anyone assist me on how to implement the above?
Thank you in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 09:57 PM
you can apply advanced ref qualifier on list collector and make it dependent on select box
Something like this
Ensure you give the correct variable name and correct sysIds for the question choices from question_choice table
javascript: var val = current.variables.selectBoxVariableName; var query; if(val == 'A' || val == 'B' || val == 'C') query = 'sysIDINChoice1SysId,Choice2SysId,Choice3SysId'; else query = 'sys_idINChoice4SysId,Choice5SysId'; query;
In variable attributes please give this
ref_qual_elements=selectBoxVariableName
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
01-07-2025 10:34 PM
Hi @Koki Sugimori
You can use this code in OnChange client script
if (g_form.getValue(choice1(A value) || choice1(B Value) || choice3(C Value)'){
g_form.addOption('list_collector_field_value','1');
g_form.addOption('list_collector_field_value','2');
g_form.addOption('list_collector_field_value','3');
g_form.removeOption('list_collector_field_value','4');
g_form.removeOption('list_collector_field_value','5');
}
else if(g_form.getValue(choice3(D value) || choice4(E Value)){
g_form.removeOption('list_collector_field_value','1');
g_form.removeOption('list_collector_field_value','2');
g_form.removeOption('list_collector_field_value','3');
g_form.addOption('list_collector_field_value','4');
g_form.addOption('list_collector_field_value','5');
}
Please check and let me know if it helpful or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 11:16 PM
This is the on change client script(on select box variable), change the "filter" as per your requirement as I used sys_user table for list collector. If you are not using none in select box remove the 3rd Else If
Mark my answer helpful if this helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 12:22 AM
Dear @PraveenK1149237, Thank you.
My explanation was insufficient. My apologies.
The solution you answered (using the catalog client script onChange) automatically sets the choices in the list collector field, but this time I want to show or hide the list of choices that can be selected in the list collector.
Can you please provide new support for the above?
Thank you in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 02:08 AM
Can you tell me is there any relation between the select box values and the values that appear on the list collector.