Expand my Community achievements bar.

Join expert-led sessions on Real-Time CDP & Journey Optimizer designed to boost your impact.
SOLVED

Equivalent of titleCase in expression

Avatar

Level 2
Level 2

Hi there, may i ask what is the equivalent of titleCase (that is found in email) I can use in expression in Custom Action Field? A typical use case/my objective is to transform JOHN SMITH EXAMPLE to John Smith Example - basically start each word with a block letter.

 

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

It's strange to see that there are multiple words in first name. 

Below is a simple example and you can expand on it using additional functions like listSize (if needed)

if ( indexOf("MOHAN DUGGANABOIENA"," ")>=0 )
then 
( 
(upper(substr(getListItem(split("MOHAN DUGGANABOIENA"," "),0), 0, 1))) + (lower( substr(getListItem(split("MOHAN DUGGANABOIENA"," "),0), 1))) + ' '+  (upper(substr(getListItem(split("MOHAN DUGGANABOIENA"," "),1), 0, 1))) + (lower( substr(getListItem(split("MOHAN DUGGANABOIENA"," "),1), 1)))
)
else 
(
(upper(substr('MOHAN', 0, 1))) + (lower( substr('MOHAN', 1)))
)

 

View solution in original post

17 Replies

Avatar

Community Advisor

Avatar

Level 2
Level 2

Hi @anuhya, that's just lower case. I need to basically start each word with a block letter. Reminder, what's the expression equivalent to the titleCase that we use in Email HTML?

 

Thanks.

Avatar

Community Advisor

@AK5 try camelCase function.

Screenshot 2025-07-02 141658.png

Avatar

Level 2
Level 2

Thanks for trying - much appreciated, don't have camel in my case:

AK5_0-1751603526840.png

 

Avatar

Community Advisor

Hi @AK5 ,

 

Try this concat(upper(substr('DAVID', 0, 1)),lower(substr('DAVID',1)))
Replace DAVID by firstname or lastname.

 

Thanks,

David



David Kangni

Avatar

Level 2
Level 2

Thanks @DavidKangni, it only formatted the first letter of the firstname: John smith example. The expected outcome is John Smith Example.

Avatar

Community Advisor

@AK5 

you can replicate the same logic for lastname

concat(upper(substr('JOHN', 0, 1)),lower(substr('JOHN',1))) +' '+concat(upper(substr('SMITH', 0, 1)),lower(substr('SMITH',1))) 



David Kangni

Avatar

Employee Advisor
(upper(substr(#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.firstName}, 0, 1))) + (lower( substr(#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.firstName}, 1)))

You can validate using an expression on the above lines

Avatar

Level 2
Level 2

Thanks @Mohan_Dugganab, the result is the same as the above solution: it only formatted the first letter of the firstname: John smith example. The expected outcome is John Smith Example. Thanks.

Avatar

Employee Advisor

Kindly try this 

(upper(substr(#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.firstName}, 0, 1))) + (lower( substr(#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.firstName}, 1))) + ' '+  (upper(substr(#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.lastName}, 0, 1))) + (lower( substr(#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.lastName}, 1)))

Avatar

Level 2
Level 2

Thanks @Mohan_Dugganab, I'm only getting the first word in uppercase and subsequent ones in lowercase: John smith example.

Any other ideas? Thanks! 

Avatar

Employee Advisor

Hopefully, you have validated with the latest expression as I see the right result being returned.

Avatar

Level 2
Level 2

Hi @Mohan_Dugganab, yes, the result i received was John smith example. Thanks.

Avatar

Employee Advisor

I ran a test and shows up correctly

Expression - 
(upper(substr('MOHAN', 0, 1))) + (lower( substr('MOHAN', 1))) + ' '+  (upper(substr('DUGGANABOIENA', 0, 1))) + (lower( substr('DUGGANABOIENA', 1)))

 

Result - 

Mohan_Dugganab_0-1752061759508.png

 

Avatar

Level 2
Level 2

Hi @Mohan_Dugganab, just to clarify, JOHN SMITH EXAMPLE is all in the firstname field. And it can be more than 3 words.

Thanks

 

Avatar

Correct answer by
Employee Advisor

It's strange to see that there are multiple words in first name. 

Below is a simple example and you can expand on it using additional functions like listSize (if needed)

if ( indexOf("MOHAN DUGGANABOIENA"," ")>=0 )
then 
( 
(upper(substr(getListItem(split("MOHAN DUGGANABOIENA"," "),0), 0, 1))) + (lower( substr(getListItem(split("MOHAN DUGGANABOIENA"," "),0), 1))) + ' '+  (upper(substr(getListItem(split("MOHAN DUGGANABOIENA"," "),1), 0, 1))) + (lower( substr(getListItem(split("MOHAN DUGGANABOIENA"," "),1), 1)))
)
else 
(
(upper(substr('MOHAN', 0, 1))) + (lower( substr('MOHAN', 1)))
)

 

Avatar

Level 2
Level 2

Brilliant! Thanks heaps @Mohan_Dugganab