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

this is the client script that i am using 

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

}

//Type appropriate comment here, and begin script below

}

try below:

 

if (!Number(newValue) || !Number(oldValue)) {
g_form.hideFieldMsg('max_waiting_time');
getMessage('Maximum waiting time should be Number'function(msg) {
 
g_form.showErrorBox('max_waiting_time', msg);
});

Raghav
MVP 2023

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 

Try this combination:
g_form.hideFieldMsg('max_waiting_time');
 
if (!Number(newValue) || !Number(oldValue)) {
g_form.hideFieldMsg('max_waiting_time');
getMessage('Maximum waiting time should be Number'function(msg) {
 
g_form.showFieldMsg('max_waiting_time', msg);
});

Raghav
MVP 2023

@kerolos samir I am not able to reproduce this error message in OOB. Which field is this? 

Is this a OOB or custom field or variable.

 

1. When I tried it on custom integer field , it turns to 0 as I enter any string value.

2. On string variable with number regex error is "Not a number".

Can you explain how to reproduce this?


Raghav
MVP 2023