Dependent value not working correctly?

Gokulraj1
Kilo Contributor

Hi team,

In incident form I am having a "category" field as reference type .So based an category the "subcategory 1" and "sub category 2" will select.

But when I click the "category" value I am not able to see the "subcategory 1" and "sub category 2"

How to fix this??

 

Regards,

Gokulraj S

 

1 ACCEPTED SOLUTION

Could you please add the sys_id under the dependent value of choices, since category is the reference field. Thanks

View solution in original post

9 REPLIES 9

Use this as the reference qualifier

javascript: new getSubCategoriesSI().getSubCategories(current.getValue('u_category'))

 

This is your script include, in this case the name of script include is getSubCategoriesSI

function getSubCategories(category) {
   var answer = [];
   var subcat = new GlideRecord('your_subcategory_table');
   subcat.addQuery('sys_id', category);
   subcat.query();
   while (subcat.next()) {
      answer.push(subcat.getValue('sys_id'));
   }
   return 'sys_idIN' + answer.join(',');
}

 

Haven't tried the code so there might be some errors in it, but should work something like that.

Gokulraj1
Kilo Contributor

I have added a choices value like below but it is not reflecting in the incident form

find_real_file.png

Incident form:

find_real_file.png

Could you please add the sys_id under the dependent value of choices, since category is the reference field. Thanks

Great ,It works perfectly.Nice job!!!!!!!!!!!!!!!!!!

Could you please show how this is done?