How to check Reference field empty value in Client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2025 05:03 PM - edited 08-05-2025 05:05 PM
Hi All,
When I selected 'None' value in reference field, alert message not coming.
OnChnage Client script
Field : Assignment Group
if(g_form.getValue('assignment_group')==''){
alert('Empty');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2025 05:25 PM
Hi @Supriya25
In ServiceNow, when you’re using an onChange client script for a reference field like assignment_group, the "None" selection (which clears the value) does set the value to an empty string '', just like you’re checking — so your condition is generally correct.
However, there are a few reasons why your alert('Empty'); may not be firing:
Make sure the client script is set correctly
Double-check that:
- Type is: onChange
- Field is: Assignment Group
- UI Type: All (or at least the one you’re testing on)
- Active: ✔️
- Isolate Script: Leave unchecked (or test both ways)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2025 05:52 PM - edited 08-05-2025 05:54 PM
yes , I'm following very thing. Still alert message not coming. not understanding that is the problem .
- Type is: onChange
- Field is: Assignment Group
- UI Type: All (or at least the one you’re testing on)
- Active:
- Isolate Script: TRUE ( tried both)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2025 05:43 PM
Hi @Supriya25 ,
in the onChange client script Boilerplate code usually you will get (newValue==='') remove it and check
if you are still facing the issue please share your entire code here
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2025 06:09 PM - edited 08-05-2025 06:10 PM
without removing (newValue==='') , I tried below two ways , you mean (newValue==='') will cause it. ?
if(g_form.getValue('assignment_group')==''){
alert('Empty');
}
or
if(newValue==''){
alert('Empty');
}