Converting a string into Title Case
Dirty or inconsistent text data, such as names entered in all caps, is common when sourced from webforms into Salesforce. This explains two practical ways to convert strings into Title Case: using Flow by splitting and rejoining words, or leveraging a small Apex class generated with AI for more flexible formatting. It highlights how AI can quickly produce helper Apex classes that integrate with Flow to clean data more efficiently. Salesforce teams can implement either solution to improve data quality and user experience without heavy Apex expertise.
- Use Flow to split words, format, and rejoin for Title Case conversion.
- Create invocable Apex classes using AI to handle complex string formatting.
- Call Apex classes from Flow to extend declarative automation capabilities.
- AI-generated Apex can be enhanced for additional case formats like camelCase.
- Controlling data input at the source is best but formatting fixes are often necessary.
When data is sourced from a webform and inserted into Salesforce, it can be dirty. Ideally, the source system has sufficient data validation in place to avoid the really dirty errors. For example, ensuring an email address has the correct format. When entering free text however, such as people’s names, things get tricky. For some reason I still cannot figure out, some people still like to write their names in full capital letters. If controlling input at the source is not possible, it’s your job to clean and format it as best as possible in Salesforce. Using the name example, there are two main ways to format the data into Title Case. Method 1: Flow Since flow can’t easily iterate over characters, you need to treat the name as a collection of words. First, split the words by looping through each word and formatting it using a formula field. Then stitch the words back together again. Method 2: Apex A tiny invocable apex class can be created using AI.