function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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. 

http://www.salesforce.com/us/developer/docs/dbcom_apex250/Content/apex_methods_system_string.htm
Shri RajShri Raj
You need to use SPLIT Methods to consider first few letters in a STRING and then use toUpperCase string method. 
AshwaniAshwani
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;
if(match.find())
{
    capitalIndex = match.start();
    break;
}
System.debug(' Index of capital letter is: '+capitalIndex);



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