AMPscript – ProperCase()

Have you ever gotten an email addressed to jane doe, (all lower case), or JANE DOE, (all upper case) or worse yet to jaNe dOe, (crazy mixed case)? All of these display because that is how the data is stored in the table. But that means nothing to the end user. They don’t remember entering it in in some crazy case, but if you display it in an email in that crazy case – they will see it. And they will judge you for it.

The good news is that it is really easy to fix with AMPscript. The ProperCase() function is what you would use. This function capitalizes the first letter character, any following character after another letter character stays in lowercase, any letter character following a non-letter character is also capitalized. Check out the examples for a better understanding.

Please note = the system doesn’t know when a 2nd letter in the name should be capitalized. So if you use the function on a name like “McDonald” it will change it to “Mcdonald”.


SYNTAX

ProperCase(@String)

Definition of parts

STRING = This is the string you want to be changed. It can be passed as a @variable or in “string format”


Simple Examples:

ProperCase(“jane doe”) → Jane Doe
ProperCase(“JANE DOE”) → Jane Doe
ProperCase(“jaNe dOe”) → Jane Doe
ProperCase(“jane asked a question”) → Jane Asked A Question


Advanced Example 1 – AMPscript Block:

%%[
VAR @firstname
set @firstname= [First Name]
set @firstname= ProperCase(@firstname)
]%%
Dear %%=v(@firstname)=%%

Advanced Example 2 – Inline:

%%[
VAR @firstname
set @firstname= [First Name]
]%%
Dear %%=ProperCase(@firstname)=%%

References:

Salesforce Developer – ProperCase()

AMPscript Guide – ProperCase()

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.