On Change Client Script - Category Based on Service

Chris_Wilkinson
Tera Expert

Hi, 

I need to create an on-change client script for the incident form to make the category field visible and mandatory when the business service is set to specific values. Does anyone know what the script would be to achieve this? 

Kind Regards

 

1 ACCEPTED SOLUTION

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Chris_Wilkinson 

 

You can use the UI policy for this. It will be low code.

 

LearnNGrowAtul_0-1706284575154.pngLearnNGrowAtul_1-1706284639129.png

 

 

*************************************************************************************************************
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]

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

View solution in original post

5 REPLIES 5

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Chris_Wilkinson 

 

You can use the UI policy for this. It will be low code.

 

LearnNGrowAtul_0-1706284575154.pngLearnNGrowAtul_1-1706284639129.png

 

 

*************************************************************************************************************
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]

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

Si11
Tera Contributor

@Chris_Wilkinson 

1. Whenever you want to make any filed Mandator or Read Only and Visible try to use the Ui policies Instead of Any script.

2. if you are having More Ui Policies on the Table then try to use the Order for the Ui policy in order to avoid any Ui policy issues.

3.If you want the Ui Polic to work on when the form is Loading then there is a Check box called " On load ", Please select that.

 

 

Regards,

Rudransh.

 

Alp Utku
Mega Sage

You can use this client script as sample

 

 

var spc = g_form.getValue('business service') ;

if (spc ==" A" || spc == "B" || spc == "C") {

g_form.setVisible('category',true) ;

g_form.setMandatory('category', true) ;

} else

g_form.setVisible('category',false) ;

g_form.setMandatory('category', false) ;

 

DanielCordick
Mega Patron
Mega Patron

You do not need a script for this. This can be easily accomplished with UI policies