If the user changes the value of the Category field,  set the default value for the Subcategory

desaiakash0
Tera Contributor
 
 If the user changes the value of the "Category" field,
 set the default value for the "Subcategory" field
 
 
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
   if(newValue=='Software'){
    g_form.setValue('subcategory','OS Issues');
   }
   else if(newValue=="Hardware"){
    g_form.setValue('subcategory','Laptop issues');
   }
   else{
    g_form.clearValue('subcategory');
   }

 

   //Type appropriate comment here, and begin script below
   
}



above script is not wokring why?
can anyone help me
1 REPLY 1

debendudas
Mega Sage

Hi @desaiakash0 ,

The script is looking good but please check the below points:

1. Check if you selected the correct "Field name" in the onchange client script.

debendudas_0-1728194430301.png

2. Please check if the values of the choices are correct or not, we need to use the value of the choices instead of the label.

3. Please check the field name of the subcategory field.

 

If this solution helps you then, mark it as accepted solution ‌‌✔️ and give thumbs up 👍