How to add more dependent values to one choice field?

brahmateja
Kilo Contributor

How to add more dependent values to one choice field?

6 REPLIES 6

Dubz
Mega Sage

You can only add 1 dependent value using the dictionary dependent value functionality, if you need to add more you'll have to use a client script to add/remove options depending on values on the form.

brahmateja
Kilo Contributor

Can you send any sample script Thanks.

It depends on the field types you're working with but i'm going to assume they're choice fields so you can use addOption() and removeOption() in an onChange script running on the category field.

The arguments for each method are ('string field name', 'choice value', 'choice label', 'choice order (optional)')

 

if(newValue == 'hardware' && g_form.getDisplayBox('assignment_group').value == 'Hardware Group'){
g_form.removeOption('subcategory', '1', 'software option');
g_form.addOption('subcategory', '2', 'hardware option');
}

 

If you're just adding or removing an option here or there you can do this in the script, if you have more complex requirements i would recommend adding the choice options in a script include and using a GlideAjax call to return the options to the client

georgeprad
Mega Expert

You can use an OnChange client script on a field to show all the options/fields you want based on the selection by the user.