Remove or edite the default error message

kerolos samir
ServiceNow Employee
ServiceNow Employee

Hi team 
Is there any way to modify this error message in the screen 
Or remove it and show another one with a client script 

17 REPLIES 17

Ravi Gaurav
Giga Sage
Giga Sage

Hi @kerolos samir 

 

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/

it didn't work 
what works is this 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (!Number(newValue) || !Number(oldValue)) {
getMessage(`Maximum waiting time should be Number ${newValue}`, function(msg) {
g_form.hideErrorBox('max_waiting_time');
g_form.showErrorBox('max_waiting_time', msg);
});

}
}
But the could not parse message appear as a flicker in the ui before the second one replaces it 

Chavan AP
Kilo Sage
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
Glad I could help! If this solved your issue, please mark it as Helpful and Accept as Solution so others can benefit too.*****Chavan A.P. | Technical Architect | Certified Professional*****