- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2020 06:39 AM
Hi All,
I have a reference field based on which other refrence field value is populated.
Not when the value in the reference field is removed(Field is empty), other dependent fields value should be cleared out.
I have written below code but its not working, please suggest
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(newValue == '')
{
//clear the value of field below
g_form.clearValue('new_log');}
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2020 06:47 AM
Hi,
If possible, it'd be nice to use a UI Policy instead for this, but...you can fix your script like so:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if(newValue == '')
{
//clear the value of field below
g_form.clearValue('new_log');}
}
}
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2020 06:47 AM
Hi,
If possible, it'd be nice to use a UI Policy instead for this, but...you can fix your script like so:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if(newValue == '')
{
//clear the value of field below
g_form.clearValue('new_log');}
}
}
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2020 07:01 AM
Thankyou very much Allen, This worked.
Would it be possible to provide some idea on why this was not working before

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2020 07:05 AM
Sure 🙂
You had these lines at the top of your script (which is there by default) on onChange client scripts:
if (isLoading || newValue == '') {
return;
}
So these lines mean if the client script is running on Load of the form...OR...if the client script is running because the new value for that field is empty/null...don't do anything else and exit, basically.
So you needed to remove the || newValue == '' from your script above because in this scenario you did want to do something if the field is set to empty/null.
Please mark this reply as Helpful if it was.
Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2020 10:13 PM
Thankyou for the details:)