- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2022 05:11 AM
I have a variable - request_type of type select box which has 3 options --> create, modify and decommission. I have another variable ci_type of type select box which has 5 options --> infrastructure, server, computer, hardware and cloud services.
The requirment is that when modify option is selected in request_type then cloud services option should be visible in the ci_type select box. If create or decomission option is selected in request_type only 4 options under ci_type option should be visible that are infrastructure, server, computer, hardware.
How to achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2022 06:07 AM
Hi Shalika,
Used Onchange client script of req_type variable in below code
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.clearOptions('ci_type', '');
return;
}
if (newValue == 'modify') {
g_form.removeOption('ci_type', 'infrastructure');
g_form.removeOption('ci_type', 'server');
g_form.removeOption('ci_type', 'computer');
g_form.removeOption('ci_type', 'hardware');
g_form.addOption('ci_type', 'cloud services', 'Cloud Services');
} else if (newValue == 'create' || newValue == 'decommission') {
g_form.removeOption('ci_type', 'Cloud Services');
g_form.addOption('ci_type', 'infrastructure', 'Infrastructure');
g_form.addOption('ci_type', 'server','Server');
g_form.addOption('ci_type', 'computer', 'Computer');
g_form.addOption('ci_type', 'hardware', 'Hardware');
}
//Type appropriate comment here, and begin script below
}
Mark Answer Helpful and Correct, if it will work

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2022 05:35 AM
Hi Shalika,
In the Choice List where your values are defined, use the "Dependent Value" field to relate ci_type values with the request_type ones.
As examples, look how the incident.category and incident.subcategory are related using that Dependent Value field.
Regards.
JP
JP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2022 05:47 AM
Hi Shalika,
https://community.servicenow.com/community?id=community_question&sys_id=59ce5250db0b9054190b1ea668961962
Regards.
JP
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2022 06:07 AM
Hi Shalika,
Used Onchange client script of req_type variable in below code
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.clearOptions('ci_type', '');
return;
}
if (newValue == 'modify') {
g_form.removeOption('ci_type', 'infrastructure');
g_form.removeOption('ci_type', 'server');
g_form.removeOption('ci_type', 'computer');
g_form.removeOption('ci_type', 'hardware');
g_form.addOption('ci_type', 'cloud services', 'Cloud Services');
} else if (newValue == 'create' || newValue == 'decommission') {
g_form.removeOption('ci_type', 'Cloud Services');
g_form.addOption('ci_type', 'infrastructure', 'Infrastructure');
g_form.addOption('ci_type', 'server','Server');
g_form.addOption('ci_type', 'computer', 'Computer');
g_form.addOption('ci_type', 'hardware', 'Hardware');
}
//Type appropriate comment here, and begin script below
}
Mark Answer Helpful and Correct, if it will work