+ Start a Discussion
sree sfdcsree sfdc 

how to retrieve the first letter capital in fields after saving ?

hi .
 I have 3 fileds in lead forum like first name ,last name ,city name .once entered data in fields (small letters) after saving it showing the first letter capital .
 how to do this ?
Shri RajShri Raj
Before inserting the record, write a trigger,. if the field is not null then use the toUpperCase string method and make it uppercase. 
Here are the string methods for reference. 

Shri RajShri Raj
You need to use SPLIT Methods to consider first few letters in a STRING and then use toUpperCase string method. 
sree sfdc,

I used to do this:

Get the String in a variable and use follwing regex:

Pattern patt = Pattern.compile("[A-Z][^A-Z]*$");
Matcher match = patt.matcher(stringValue);

integer capitalIndex = -1;
    capitalIndex = match.start();
System.debug(' Index of capital letter is: '+capitalIndex);

After getting the index greater than -1 you can do any operation with it.