Remove or edite the default error message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
The default error ( “Could not parse xxx as an integer” ) is coming from ServiceNow’s internal field type validation because your field is defined as Integer in the dictionary. That system validation always runs before/alongside your client script, and unfortunately you cannot "turn it off" for that field type.
Script Modified :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (isNaN(newValue)) {
g_form.showFieldMsg('max_waiting_time',
'Maximum waiting time should be a number (in seconds).', 'error');
} else {
g_form.hideFieldMsg('max_waiting_time');
}
}
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
it didn't work
what works is this
But the could not parse message appear as a flicker in the ui before the second one replaces it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Fix Options
Option 1: Direct Message (Recommended)
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') return;
if (!Number(newValue)) {
g_form.showErrorBox('max_waiting_time', 'Maximum waiting time must be a valid number');
}
}
Option 2: Proper getMessage Usage
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') return;
if (!Number(newValue)) {
getMessage('max_waiting_time_error', function(msg) {
g_form.showErrorBox('max_waiting_time', msg);
});
}
}
Then create sys_ui_message record:
Key: max_waiting_time_error
Message: Maximum waiting time must be a valid number