Duration type field should accept only numeric value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 04:23 AM
Hi ,
Currently time_worked field is accepting alphabets with including numeric value but as per the requirement it should not accept alphabets and special characters . Can anyone help me on this requirement. Thanks in advance.
Time worked field type is "Duration".
i have written onchange client script as below
var numericRegex = /^[0-9].*/;
var numnericVal = g_form.getValue('time_worked');
if (!numericRegex.test(numnericVal)) {
alert("Please enter numeric values");
g_form.setValue('time_worked', '');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 05:18 AM
it's OOB filed so ideally it should not accept characters.
Did you check any OOB script exists to handle this validation for any OOB field?
The same you can replicate for your field
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 05:23 AM
Hi @Ankur Bawiskar ,
Thanks for quick reply
I have tried as per knowledge but i didn't get it.
Can you please suggest any OOB script which handles this validation.
Awaiting for your reply.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 05:26 AM
Hi Ankur,
Thanks for quick reply,
I tried from my end but i didn't find it.
Can you suggest me any OOB script if you find.
Awaiting for reply.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 09:04 PM
Seems platform bug I checked by applying the same on OOB duration field.
It seems g_form.getValue() doesn't work on duration field
Check this link. I was unable to open it
https://hishowcase.service-now.com/kb?id=kb_article_view&sysparm_article=KB0752390
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