Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Camel case on string

Alexandre17
Tera Expert

Hello. How i change UPPER LETTER to Camel Case ?

var busca_resp = new GlideRecord('sys_user');
busca_resp.addQuery('name', "alexandre");
busca_resp.query();
if(busca_resp.next()){
gs.info("The name is : " + busca_resp.name);
gs.info("The title is : " +  busca_resp.title);
}

The print is:

 

x_xxx_xxx_xxxxxxxx: The name is : Alexandre
x_xxx_xxx_xxxxxxxx: The title is : ANALISTA TEC

But i need:  Analista Tec

1 ACCEPTED SOLUTION

Mike_R
Kilo Patron
Kilo Patron

Idk if this is the most efficient, but seems to work

 

var original = "ANALISTA TEC";
var sp = original.split(' ');
var newStr = '';


for( var i=0; i<sp.length; i++){
var newStr = newStr + sp[i].charAt(0).toUpperCase() + sp[i].substr(1).toLowerCase() + " " ;

}

gs.print(newStr.trim());

 

 

 

*** Script: Analista Tec

View solution in original post

3 REPLIES 3

Mike_R
Kilo Patron
Kilo Patron

Idk if this is the most efficient, but seems to work

 

var original = "ANALISTA TEC";
var sp = original.split(' ');
var newStr = '';


for( var i=0; i<sp.length; i++){
var newStr = newStr + sp[i].charAt(0).toUpperCase() + sp[i].substr(1).toLowerCase() + " " ;

}

gs.print(newStr.trim());

 

 

 

*** Script: Analista Tec

Alexandre17
Tera Expert

@Mike_R, its worked...... tks

Awesome, no problem!