Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to clear value of variable on 'uncheck' of checkbox

nicolemccray
Tera Expert

I need to clear the value entered in a field (members_move_group) when a checkbox is unchecked (or 'false'), but it will not clear.  I have an onChange script that is not working:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}

//Type appropriate comment here, and begin script below
var move = getValue('move_members_different');
if (move == 'false'){


g_form.setValue('members_move_group','');


}
}

 

1 ACCEPTED SOLUTION

Shashikant Yada
Tera Guru

Try below code:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}

//Type appropriate comment here, and begin script below
var move = g_form.getValue('move_members_different');
if (move == 'false'){


g_form.setValue('members_move_group','');


}
}

View solution in original post

3 REPLIES 3

Shashikant Yada
Tera Guru

Try below code:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}

//Type appropriate comment here, and begin script below
var move = getValue('move_members_different');
if (move == 'false'){


g_form.setValue('members_move_group','false');


}
}

 

Shashikant Yada
Tera Guru

Try below code:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}

//Type appropriate comment here, and begin script below
var move = g_form.getValue('move_members_different');
if (move == 'false'){


g_form.setValue('members_move_group','');


}
}

Argh!  Forgot the g_form.  Thank you!