We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

CAPITAL letters(upper case) change to (lower case)

Mohamed Aashik
Tera Contributor

my problem is that people enter the name in full caps (ex: MICHAEL) instead of (ex: Michael)
is there a way to change all the caps?

4 REPLIES 4

Raghav Sharma24
Giga Patron

there are 2 string operation toLowerCase() and toUpperCase()

You can use them.

Not applicable

Hi @Mohamed Aashik ,

the field where you want to make the first letter uppercase and rest lowercase?

The basic script to do something like that is as follows:

 

var str = "test";
//Making sure that everything is converted to lowercase first
str = str.toLowerCase();
//Making the first character uppercase
var newStr = str.charAt(0).toUpperCase() + str.slice(1);

//result for this code -> str: test, newStr: Test

 

 

Saurabh Gupta
Kilo Patron

Please try using below script

 

function getPropercase(str)
{
    if(str)
    return str.charAt(0).toUpperCase()+str.toLowerCase().substring(1);
    else
    return "";
}

gs.info(getPropercase("SAURABH"))
gs.info(getPropercase("saurabh"))
gs.info(getPropercase("SaUrAbh"))

Thanks and Regards,

Saurabh Gupta

Saurabh Gupta
Kilo Patron

Hi @Mohamed Aashik 

 

 


Thanks and Regards,

Saurabh Gupta