Upper Case - String Field

Rhane
Kilo Explorer

What is the easiest way to make it so a string field convert into all upper case?
That way all of the text being entered can have all upper case letters.

Is there a way to have it automatically change to Upper case while the person is typing in even though they dont have CapsLock on? (Chances are they don't know it needs to be all upper case) Or maybe a on submit script would be easiest?

I saw the Field Normalization plugin might be a way to go. But if there is an easier way to do this, it would be much appreciated.

Thanks in advanced.

4 REPLIES 4

CapaJC
ServiceNow Employee
ServiceNow Employee

You could do it with an onChange Client Script on the field. Won't happen as they type, but will convert when they move to another field. In this example, the field is incident.short_description:



function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '')
return;

var str = newValue.toUpperCase();
if (str != newValue)
g_form.setValue("short_description", str);
}


geoffcox
Giga Guru

This onload client script is currently running on the demo13 instance, change request form, short description field:



function onLoad() {
//Type appropriate comment here, and begin script below
var field = document.getElementById('change_request.short_description');
field.onkeyup=upperCase;
}

function upperCase() {
var x = document.getElementById('change_request.short_description');
x.value = x.value.toUpperCase();
}


Rhane
Kilo Explorer

These are exactly what I was looking for. Thanks for the help CapaJC and geoffcox.


Patricio Javier
Tera Contributor

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '')
return;

if (newValue.toUpperCase() != newValue)
g_form.setValue("field", newValue.toUpperCase());

}