How to show and hide one choice value based on category selection

VIKAS MISHRA
Tera Contributor

If someone select category "A" on the portal then only sub category "X" should be visible. 

And if user unselect the category from A to somthing else then sub category "X" should again be hidden, 

Please suggestion how to do it 

5 REPLIES 5

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @VIKAS MISHRA 

 

You need to to write the client script for the same. 

As you are hiding the value. 

 

https://www.servicenow.com/community/incident-management-forum/hide-subcategory-option-based-on-cate...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

I am writing below mentioned script but that one

function onChange(control, oldValue, newValue, isLoading) {
  if (isLoading ) {
	if(g_form.getValue('category') != 'Business Application'){
		g_form.removeOption('subcategory', 'Costa Loyalty – Poland');
	}
       return;
    }

var cat = g_form.getValue('category');
var subcat = g_form.getValue('subcategory');
if (cat != 'Business Application') {
g_form.removeOption('subcategory', 'Costa Loyalty – Poland');
}}

is not working.

pra16
Tera Contributor

Hi Vikas,

 

To avoid scripting, this can also be done using dictionary dependency. You can add dependencies in sub-category field for required category values respectively.

 

Please mark it helpful if I could help with your query.

This option is not aviable for portal fields/variables