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
RepsGRepsG 

Title Case Trigger

HI,

 

I'm new to Apex Code and would like help to create a trigger that converts text within a field to Title Case.

For example: 12 NEW STREET  converted to 12 New Street.

 

Can anyone help

 

Thanks in advance

waylonatcimwaylonatcim

There is another post here which discusses making the first character of each word in a string uppercase.  Do you need help writing the actual trigger or just with the string manipulation?

Jayu BJayu B

Hi,

I am finding th solution for this functionality for First name and Last name..

I  got one code like : UPPER(LEFT(FirstName,1))&LOWER(Mid(FirstName, 2, Len(FirstName)-1))

 

Thanks.

RepsGRepsG

Hi Jayu,

 

Your best friend should be the Apex Code Developer guide (PDF). This guide will have all the methods and examples of how to use the methods.

 

For example for your problem you need view all string methods and within the string method section of the PDF you will come across a method called capitalise.

 

the example given in the document is the following:

 

string s = 'hello'

 

string s2 = s.capitalise();

 

therefore value in s2 will be 'Hello'

 

You will need to do the following in your code.

 

instead of declaring another string variable you use the line below.

 

Firstname = Firstname.capitalise();

 

Hope this helps if not please check the string methods.

 

If you need further help, let me know.

 

take care