Show sub category field based on resource group field action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2024 12:53 AM
Hi,
I need to add two new fields to the form:
1.Resource Group: (dropdown list) Interims, Persistent Externals, Occasional Externals, Non-Executives
2. Resource Sub group to display based on resource group selected:
-Interims
Interims - via Assured Partner
Interims - Independents
-Persistent Externals
Persistent Externals - via Assured Partner
Persistent Externals - Independents
-Occasional Externals
Occasional Externals - via Assured Partner
Occasional Externals - Independents
Non-Executives (no additional resource sub group dropdown required for this)
And now I don't know how to do it best. I created two select boxes with options but I don't know how to make them show up depending on the selection because in UI Policy you can't select a value from another variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2024 01:17 AM
Please give us more context in your questions so that we can answer your query better. In catalog item, you can't make such dependency as I mentioned. You have to write a client script.
Use g_form.addOptions(),g_form.clearOptions() methods.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2024 01:20 AM
I want the variables in the catalog item to be displayed appropriately matched to the selection.
That is, if Intermis is selected in the resource_group variable, only those designated for this selection will be displayed from the resource_sub_group variable, the same for the rest of the examples
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2024 01:21 AM - edited ‎09-02-2024 02:05 AM
Hi @New user1212,
Use this code as a Reference:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
// Putting some context, newValue is the variable storing changed value of the
// dependency variable, in your case is Resource Group which will be selected in Variable
// field of Catalog Client Script.
alert('SAR1');
if (isLoading || newValue == '') {
alert('SAR2');
g_form.clearOptions('e_voucher_brand', '');
return;
}
if (newValue == 'E-Commerce') {
alert('SAR3');
g_form.clearOptions('e_voucher_brand', '');
g_form.addOption('e_voucher_brand', 'Flipkart', 'Flipkart');
g_form.addOption('e_voucher_brand', 'Amazon', 'Amazon');
g_form.addOption('e_voucher_brand', 'Myntra', 'Myntra');
}
else if (newValue == 'Shopping') {
alert('SAR4');
g_form.clearOptions('e_voucher_brand', '');
g_form.addOption('e_voucher_brand', 'Lifestyle', 'Lifestyle');
g_form.addOption('e_voucher_brand', 'Allen Solly', 'Allen Solly');
}
else if (newValue == 'Sports Wear') {
alert('SAR5');
g_form.clearOptions('e_voucher_brand', '');
g_form.addOption('e_voucher_brand', 'Puma', 'Puma');
g_form.addOption('e_voucher_brand', 'Adidas', 'Adidas');
g_form.addOption('e_voucher_brand', 'Nike', 'Nike');
}
else if (newValue == 'Food Delivery') {
alert('SAR6');
g_form.clearOptions('e_voucher_brand', '');
g_form.addOption('e_voucher_brand', 'Zomato', 'Zomato');
g_form.addOption('e_voucher_brand', 'Swiggy', 'Swiggy');
}
}
If you found my response helpful, please mark it as Solution and Helpful.
Thanks and Regards,
Ehab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2024 01:11 AM
Right click on the field on form and select configure dictionary
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2024 01:12 AM
this is a variable in the catalog item, not incident variable