when one reference field is empty the other reference field should be empty. how can we achieve it?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2025 06:53 PM
when one reference field is empty the other reference field should be empty. how can we achieve it?
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2025 07:38 PM
@sariksorte You can write an onChange client script on the first reference field as follows.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == oldValue) {
return;
}
// If the reference field is cleared, clear the dependent field
if (!newValue) {
g_form.clearValue('u_other_reference_field');//clear other reference field
}
}
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2025 08:07 PM
you can use onChange client script on 1st field and empty the 2nd one
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
// If the reference field is cleared, clear the dependent field
if (newValue == '') {
g_form.clearValue('2ndField');
}
}
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader