- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2025 09:30 PM
I have created a List collector Variable in Service Catalogue and created their 3 choices ( A , B , C) and get it referenced through question_choice table. Now the requirement is that when I select the B choice then I should not get the option to select C option and vice versa. But for Option A , I can select all 3 choice.
Please assist.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2025 01:12 AM
Hi @akchauhan
I have tried in PDI . Its working as expected . PFA code and screenshot for your reference.
Note:- I have used hardcoded sys_id of choices.
Explanation:
- Selection Rules:
- If B and C are both selected together, regardless of whether A is selected, the script triggers an alert and clears the List Collector value.
- Behavior:
- Users can select any single option or combinations like A + B or A + C.
- Users cannot select B and C together, even if A is included.
Testing:
- Test Cases:
- Select B and C → Alert should appear, and the value should clear.
- Select A and B or A and C → Selection should be allowed.
- Select A, B, and C → Alert should appear, and the value should clear.
- Select A only → Selection should be allowed.
Code :-
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2025 09:44 PM
Hello,
See if this below script works.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var parm = (window === null) ? 'portal' : 'native';
var varName = 'your_list_var_name';
var filterString = '';
var choiceA = 'choice_a_sys_id';
var choiceB = 'choice_b_sys_id';
var choiceC = 'choice_c_sys_id';
if (newValue.indexOf('Choice A') != -1) {
filterString = 'sys_idIN' + choiceA + ',' + choiceB + ',' + choiceC;
} else if (newValue.indexOf('Choice B') != -1) {
filterString = 'sys_idIN' + choiceB;
} else if (newValue.indexOf('Choice C') != -1) {
filterString = 'sys_idIN' + choiceC;
}
if (parm == 'portal') {
var myListCollector = g_list.get(varName);
myListCollector.reset();
myListCollector.setQuery(filterString);
} else {
window[varName + 'g_filter'].reset();
window[varName + 'g_filter'].setQuery(filterString);
window[varName + 'acRequest'](null);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2025 09:50 PM
what happens if option B or C is selected in combination with A?
Is this an actual business requirement?
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-02-2025 10:10 PM
Dear Ankur,
many thanks for your response.
With A, either B or C can be selected but B&C cannot be selected at one go either with A or without A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2025 10:28 PM
simply use onSubmit catalog client script
function onSubmit() {
var valueSelected = g_form.getValue('listCollectorVariableName');
if (valueSelected.indexOf('choiceBSysId') > -1 && valueSelected.indexOf('choiceCSysId') > -1) {
g_form.addErrorMessage('Please select either option B or option C');
return false;
}
}
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