- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2014 11:29 AM
Hi sach,
We created separate global function which can be used anywhere (UI Script). we had some extra things to take care as well.
Following is the workaround:
function removeOptions(selectbox,choiceValue)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
if (selectbox.options[i].value == choiceValue) {
selectbox.remove(i);
break;
}
}
}
//using the function:
removeOptions(document.getElementById("mySelectObject"),choiceValue);
this works on all browsers
Hope it Helps !