Proper Case First Name in a Widget Server Script

Steven Parker
Giga Sage

If I am using the below function to get the first name of the logged in user in the "Server Script" on a widget...How can I ensure the name is in the proper case (Capital first letter and lower case all the remaining letters) within this function?

 

(function() {
  data.user = gs.getUser().getFirstName();
})();

 

 


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
1 ACCEPTED SOLUTION

@Ankur Bawiskar 

This works....any negative side effects using substring?

  var firstName = gs.getUser().getFirstName();
  data.user = firstName.substring(0,1).toUpperCase() + firstName.slice(1).toLowerCase();

 


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

View solution in original post

5 REPLIES 5

@Steven Parker 

Did you accidentally marked your own response as correct?

Would you mind marking my below response as correct if that helped as it has a working solution as well?

 

AnkurBawiskar_0-1746620948639.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader