- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2017 01:29 AM
Hi All,
I have 3 fields and they are choice field with dependency
Some choice in the 2nd field don't have any depended values in the 3 field.
I want to hide the 3 field if there are no depended choices.
Its a bit similar to OOB category/subcateogry except they don't hide the field if there are no sub categories.
Any suggestions welcome
Thanks,
Ellie
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2017 02:15 AM
You can use the following script:-
- var gp = new GlideRecord('sys_choice');
- gp.addQuery('dependent_value', newValue);
- gp.addQuery('element', 'subcategory'); //If you have a label for it
- gp.query();
- if(!gp.next())
- {
- g_form.setVisible('your variable', false);
- }
It might NOT be exactly the same, you might need to tweak it a bit but this is the general idea.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2017 02:01 AM
Hi Ellie,
You will have to run onChange Client Script when you are changing the Cat 2 level field, query if that has any Cat 3 values, if results returned, do nothing, if results not returned, hide the field on the form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2017 02:09 AM
Hi Das,
Do you mean GlideAjax? can you offer any help with this script
The field to hide if it IT Service choice has no IT Service component is it_component.
Many Thanks,
Ellie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2017 02:15 AM
You can use the following script:-
- var gp = new GlideRecord('sys_choice');
- gp.addQuery('dependent_value', newValue);
- gp.addQuery('element', 'subcategory'); //If you have a label for it
- gp.query();
- if(!gp.next())
- {
- g_form.setVisible('your variable', false);
- }
It might NOT be exactly the same, you might need to tweak it a bit but this is the general idea.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2017 03:08 AM
Hi Das,
This is very helpful and I can tweak the script but can't quite get it to work
With the tweaked script below it always hides the it_service_component field even if it has a value or more.
var gp = new GlideRecord('sys_choice');
gp.addQuery('dependent_value', newValue);
gp.addQuery('element', 'u_it_service'); //If you have a label for it
gp.query();
if(!gp.next())
{
g_form.setVisible('u_it_service_component', false);
}
Any idea?
Many Thanks,
Ellie