- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 09:21 AM
Hi Everyone, I'm trying to write a simple onChange client script that clears values based on an answer:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue==='') {
return;
}
if(g_form.getValue('relation_to_employee').indexOf("child") == -1) {
g_form.clearValue('x_dnf_gw_found_type_of_child');
g_form.clearValue('x_dnf_gw_found_dependent');
}
}
So if Relation to Employee does not equal "child" then I want to clear the values for Type of Child and Dependent fields. This works fine, but the Relation to Employee drop down has "-- None --'" and for some reason, this doesn't work. I've tried changing my if statement to the following but it still doesn't work:
if(g_form.getValue('relation_to_employee', '!=','child') || g_form.getValue('relation_to_employee','')){
Any suggestions on how to fix this? Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 09:26 AM
The option of "--None--" has a value of "". If you change your script to this it should work;
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if(g_form.getValue('relation_to_employee').indexOf("child") == -1) {
g_form.clearValue('x_dnf_gw_found_type_of_child');
g_form.clearValue('x_dnf_gw_found_dependent');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 09:26 AM
The option of "--None--" has a value of "". If you change your script to this it should work;
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if(g_form.getValue('relation_to_employee').indexOf("child") == -1) {
g_form.clearValue('x_dnf_gw_found_type_of_child');
g_form.clearValue('x_dnf_gw_found_dependent');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 09:43 AM
Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2019 01:42 AM
Hi, I have a similar issue.
I have a client script which populates the subcategory based on category chosen. Category is actually dependent on another field called support area. when we have a category which only has one subcategory, the client script will automatically populates the subcategory. Once it's populated, not able to clear it which runs on the change of Support area field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2019 09:06 AM
I'd suggest opening a new post on this different issue. I don't have a fast/quick answer. Sorry.