Catalog Item - Select Box variable dependent on other select box variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 02:04 AM - edited 02-06-2023 02:06 AM
Hello,
I have created a catalog item in which Question 1 type is select box, if here user selects an option based on that Question 2(select box) options should be shown.
I tried to achieve this with help of client script (type - onchange) using addOption() and removeOption().
This is not working properly when I select option 1 from Question1 then change is in seen in the Question 2 option but when I immediately change the Question1 to option2 the options for Question2 is not changed unless I don't refresh the service portal form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 06:38 AM
Because of this possibility/likelihood that the value for Question1 could change more than once, your script needs to comprehensively account for each value. We do this in an onChange script with a series of if statements that get rid of all options, then adds back the appropriate ones like this:
g_form.clearOptions('v_inquiry_subtype');
if (newValue == 'Connectivity') {
g_form.addOption('v_inquiry_subtype', '', '-- None --');
g_form.addOption('v_inquiry_subtype', 'activation', 'Activation / Re-Activation');
g_form.addOption('v_inquiry_subtype', 'roaming', 'Roaming / International');
}
if (newValue == 'Hardware') {
g_form.addOption('v_inquiry_subtype', '', '-- None --');
g_form.addOption('v_inquiry_subtype', 'sim_replace', 'SIM card replacement');
}
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 06:44 AM
check this link and this should help you
Using Category and Subcategory on ServiceNow Record Producers
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
09-09-2024 09:59 AM
Thanks for your link . The Article is very helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2023 03:05 AM
Please refer to this article I thought this will be work
for your Requirements
Thanks !