- 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-08-2025 08:20 PM
I am sorry that I do not quite understand the intent of your question.
What do you mean by “some kind of relationship”?
【To add to my reply yesterday】
If I select A in the select box, when I open the pull-down in the list collector, it shows 4 and 5, which are not related to each other.
I mean I want to hide this.
If you know of any solution to this, please support me.
Thank you in advance.
- 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-09-2025 06:28 PM
Thank you very much.
For me, this solution is very helpful.
I would like to confirm one point.
I changed the ref qualifier you gave me to the correct variable name and sysIds, but all records in the [question_choice] table show up in the list collector.
Shouldn't it be javascript: not javascript:?
【ref qualifier:Before modification】
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;
【ref qualifier:After modification】
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;
I would appreciate confirmation on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 06:40 PM
I also informed to give the variable attributes for the list collector. Did you give that?
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-09-2025 09:03 PM