Below client script is not working

Jyothsna5
Tera Contributor
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

    // set value in property subcategory based propert
    if ( g_form.getValue('property') == 'detached_house') {
        g_form.setValue('property_subcategory', '3_bedroom_detached_house', '3 Bedroom Detached House');
       
    } else if ( g_form.getValue('property') == 'apartment') {
        g_form.setValue('property_subcategory', '3_bedroom_apartment', '3 Bedroom Apartment');
       
    } else if ( g_form.getValue('property') == 'town_house') {
        g_form.setValue('property_subcategory', '3_bedroom_town_house', '3 Bedroom Town House');
       
    }
 
}
1 ACCEPTED SOLUTION

Bhuvan
Kilo Patron

@Jyothsna5 

 

You client script is working fine with provided script,

Bhuvan_0-1754395718820.png

Check if you have configured UI Type, Type, Field name for on change condition and field names used for property, property subcategory in the client script and their values are correct.

 

Bhuvan_1-1754395770332.png

Thanks,

Bhuvan

 

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Jyothsna5 

others already pointed out, setValue() only accepts 2 parameters.

Please refer docs going forward for any syntax for g_form methods

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader