How can I hide a field if selection on dependant field has no choices

E_19
Giga Expert

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

1 ACCEPTED SOLUTION

You can use the following script:-


  1. var gp = new GlideRecord('sys_choice');  
  2. gp.addQuery('dependent_value', newValue);  
  3. gp.addQuery('element', 'subcategory');   //If you have a label for it
  4. gp.query();  
  5. if(!gp.next())
  6. {  
  7.   g_form.setVisible('your variable', false);
  8. }

It might NOT be exactly the same, you might need to tweak it a bit but this is the general idea.


View solution in original post

6 REPLIES 6

Thanks Das this is working now I found that a UI Policy caused a conflict.


Need to add the fields are all on incident table