You need to sign in to do that
Don't have an account?
angusgrant
Make first Letter for FirstName / LastName Upper case apex visualforce page
How can i convert the firstname and Lastname first character to uppercase?
Sorry I am not a Java coder so am not sure how this is done.
Hi,
You can create a new method that change the first letter to upper case. Something like this
Example:
nameFormat('foo') >>> return 'Foo'
nameFormat('foo and more foo') >>> return 'Foo And More Foo'
I hope it help you :D
J
All Answers
Hi,
You can create a new method that change the first letter to upper case. Something like this
Example:
nameFormat('foo') >>> return 'Foo'
nameFormat('foo and more foo') >>> return 'Foo And More Foo'
I hope it help you :D
J
Hi thanks for providing this for me.
i actually managed to get to the answer a bit quicker than I got your post. However I can see that your method would be better if the applicant have double barelled name etc..
String FirstName = Contact.FirstName; String LastName = Contact.LastName; FirstName = FirstName.substring(0,1).toUpperCase() + FirstName.substring(1).toLowerCase(); LastName = LastName.substring(0,1).toUpperCase() + LastName.substring(1).toLowerCase();
Yes, also you have to be careful when the string is null , empty or have only one char.
Example:
Contact.firstName = 'a';
Contact.lastName = 'b';
Throw an error with the index of the substring method :
Contact.firstName = null;
Contact.lastName = null;
Throw an error :
Regards
J.
String FirstName = Contact.FirstName; String LastName = Contact.LastName; if (FirstName != null && LastName != null && FirstName != '' && LastName != ''){ if (FirstName.length() > 1 && LastName.length() > 1) { FirstName = FirstName.substring(0,1).toUpperCase() + FirstName.substring(1).toLowerCase(); LastName = LastName.substring(0,1).toUpperCase() + LastName.substring(1).toLowerCase(); } //creat a validation rule to make sure Firsname and Lastname is greater than 1 character in sf } //we dont need an else statment here as the try catch block around the Contact should catch this error