- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2014 05:14 AM
Hi ServiceNow Developers,
I am looking for a way if there is one, to check and make sure that there is a value on a glide list field before it is submitted. In other words I am looking for something like getValue() that will check the value of a field and if the result of getValue() is spaces / empty then I issue an alert / error message and force the users to enter something. Is there a way I can validate the glide list field using client script to check and make sure that there is something on this field before the form is submitted. Please advise.
Thanks,
Johannes
Solved! Go to Solution.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2014 06:39 AM
Works as well, should have thought about this earlier
So the modified code would be:
function onSubmit() { if (g_form.isNewRecord()){ g_form.hideFieldMsg('u_list'); if(g_form.getValue('u_list')==''){ g_form.showFieldMsg('u_list','List is empty.','error'); return false; } } }
Kind regards,
Sascha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2014 06:39 AM
Works as well, should have thought about this earlier
So the modified code would be:
function onSubmit() { if (g_form.isNewRecord()){ g_form.hideFieldMsg('u_list'); if(g_form.getValue('u_list')==''){ g_form.showFieldMsg('u_list','List is empty.','error'); return false; } } }
Kind regards,
Sascha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2014 07:13 AM
Wow, it works!!
Thank you very much guys, I will replace the business rule that I already have in production with this solution which I think works better because it's client side (before the form gets submitted).
Regards,
Johannes