- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2014 08:26 AM
Hi Matt,
If you are going to use the Category/Subcategory on multiple forms, I would definately recommend a variable set.
The link below will take you to a wiki article that should help you create the dependencies
https://wiki.servicenow.com/index.php?title=Adding_Dependent_Variables
Thanks,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2014 08:56 AM
Thank you for the answer but I guess I'm still confused . I'm still not sure how variable sets work and how I can use variable sets with this method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2014 02:28 PM
Hi Matt,
When variables are grouped together they are called variable sets. variable sets are reusable. They can be used across different catalog items. However normal variable belong to that specific item only. Following is the link.
Service Catalog Variable Sets - ServiceNow Wiki
Regarding Dependent choice list, you can use simple client script based.
You will need following things:
On change of category
function onChange(control, oldValue, newValue, isLoading) {
if(newValue == oldValue){
return;
}
//remove all items from subcat drop down to start
// Used the g_form.clearOptions() function instead of g_form.removeOption() function
g_form.clearOptions('subcat');
//build a new list of dependent options
var gp = new GlideRecord('sys_choice');
gp.addQuery('dependent_value', newValue);
gp.addQuery('element', 'subcategory');
gp.query();
while(gp.next()){
g_form.addOption('subcat', gp.value, gp.label);
}
}
Additional OnLoad script to initially clear the Subcategory
function onLoad (control, oldValue, newValue, isLoading) {
// Used the g_form.clearOptions() function instead of g_form.removeOption() function
g_form.clearOptions('subcat');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2014 11:17 AM
bajarang..g_form.clearOptions('u_sub_2'); does not work on Internet Explorer .
Is there any thing else that will clearOptions from IE ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2014 11:19 AM
Hi Sach,
I'll also check this and get back to you on this
Regards,
Solutioner