- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2014 06:51 AM
I'm creating a record producer where a category and subcategory is shown.
Subcategory and category are both custom variables that are drop down lists. But I want the subcategories to be based off what category is shown.
For example when someone chooses phone for the category I'd like the subcategory to show phone related items.
Would this be a good place to use variable sets?
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2014 01:31 PM
I don't see a dependent in catalog variables like they have in Choice lists on forms. What you might need to do is use the catalog UI policies. Make a different sub-cause for each choice in the cause. So if you had 5 causes, then there would be 5 different sub cause variables. Then use the UI policies to hide the different sub causes until the correct cause is chosen. This sounds messy, so hopefully someone else can come up with a better idea.

- 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 ?