need help in cilent script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2024 09:24 PM
Hi Team
can any one please help me , in this request
for the particular catalog item , Based on the type of request , Infrasturure request should populate .
can any one please provide me script for this .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2024 10:03 PM
Hi @nameisnani
Please refer the below links
https://www.servicenow.com/community/developer-articles/creating-dependent-variables-in-service-cata...
Please mark helpful & correct answer if it's really worthy for you.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2024 10:27 PM
Hello
Try the below code make sure you are using correct backend values
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var infrastructureRequest = 'infrastructure_request'; // Replace with the actual variable name for Infrastructure Request
// Clear current options
g_form.clearOptions(infrastructureRequest);
// Add options based on the selected type of request
if (newValue === 'Kyndryl Mainframe') {
g_form.addOption(infrastructureRequest, 'request_for_information', 'Request for Information');
g_form.addOption(infrastructureRequest, 'audit_enquiries', 'Audit Enquiries');
g_form.addOption(infrastructureRequest, 'data_extract', 'Data Extract');
g_form.addOption(infrastructureRequest, 'infrastructure_design_enquiries', 'Infrastructure Design Enquiries');
g_form.addOption(infrastructureRequest, 'shared_folder_access', 'Shared Folder Access');
g_form.addOption(infrastructureRequest, 'storage_backup', 'Storage & Backup');
} else if (newValue === 'AWS') {
g_form.addOption(infrastructureRequest, 'request_for_information', 'Request for Information');
g_form.addOption(infrastructureRequest, 'audit_enquiries', 'Audit Enquiries');
g_form.addOption(infrastructureRequest, 'data_extract', 'Data Extract');
g_form.addOption(infrastructureRequest, 'infrastructure_design_enquiries', 'Infrastructure Design Enquiries');
g_form.addOption(infrastructureRequest, 'shared_folder_access', 'Shared Folder Access');
g_form.addOption(infrastructureRequest, 'storage_backup', 'Storage & Backup');
} else {
// Add default options or handle other cases if necessary
g_form.addOption(infrastructureRequest, 'default_option', 'Default Option');
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards
Priyanka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2024 10:35 PM
Hi @nameisnani
Please follow below steps :
1. Configure your variable Infrastructure request with all the drop-down choices as shown below :
2. Create an On-Change Catalog Client Script on Type of Request variable :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var type = g_form.getValue('type_of_request');
if (type == 'kyndryl') //use the backend value of the Knydrnl Mainframe
{
g_form.removeOption('infrastructure_request', 'shared_folder_access');
g_form.removeOption('infrastructure_request', 'storage_and_backup');
g_form.removeOption('infrastructure_request', 'patch_management');
} else if (type == 'aws') {
g_form.addOption('infrastructure_request', 'shared_folder_access', 'Shared Folder Access');
g_form.addOption('infrastructure_request', 'storage_and_backup', 'Storage & Backup');
g_form.addOption('infrastructure_request', 'patch_management', 'Patch Management');
}
}
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2024 11:26 PM