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 06:16 PM
Hi @Supriya25 ,
if you have something like this in your code
when the group value is empty it will hit the return statement and other line will not run
you convert it to something like this
if (!newValue) {
alert('EMPTY');
}
please share you code and client script screenshots if you are still facing the issue
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:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2025 06:26 PM
Hi @Supriya25 ,
To detect when a reference field such as Assignment Group has been cleared (i.e. set to “ None ”), ensure your onChange client script does not exit when newValue === ''; instead, remove that condition so if (g_form.getValue('assignment_group') == '') { alert('Empty'); } will successfully trigger the alert.
Try this once and let me know. If you find this helpful, please accept this as a solution and hit the helpful button..
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2025 09:00 PM
if it's a reference field then why it's showing None option and why it's a drop down?
what type of field is that? share screenshots
what's your business requirement?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader