The CreatorCon Call for Content is officially open! Get started here.

Setting field to null based on true/false field

carlocsa
Kilo Expert

Hi ServiceNow Gurus,

In have 2 fields:

u_field_a is a text field, u_field_b is a true/false field

by default, u_field_a contains a value (ex. "string") and u_field_b is true

what i want to achieve is to clear u_field_a when u_field_b is set to false.

please help.

thank you very much.

Carlo

 

1 ACCEPTED SOLUTION

Ujjawal Vishnoi
Mega Sage

Hi Carlo,

You can also use onChange client script for field u_field_b if you want to clear the field a as soon as we change the field b to true.Please refer screenshot below.

find_real_file.png

script-----

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue=='false')
g_form.setValue('u_field_a','');

}

 

Hope this helps.

Regards

Ujjawal

View solution in original post

6 REPLIES 6

Agree Jon, we should go with a Business rule, But i have seen the cases where we have to clear the any field on change of something, sothat user need not to clear it manually and he can fill the information in string field.

Regards

Ujjawal

Yes definitely! I have had that use case many times too. I just wanted to remind the original poster to still do the BR even if he does the client script for that reason.

 

thanks