0

We are using a data extension to populate a subject line with the first name and it looks like this:

%%[ 
VAR @FIRST_NAME 
SET @FIRST_NAME = [FIRST_NAME] 
/*SET @FIRST_NAME = "test"*/ 
if length(@FIRST_NAME) > 2 then 
  /* Capitalize */ 
  SET @FIRST_NAME = ProperCase(@FIRST_NAME) 
else /* All Caps */ 
  SET @FIRST_NAME = Uppercase(@FIRST_NAME) 
endif ]%% 



%%[ 
if Length(@FIRST_NAME) < 3 then 
  Output(V(Concat("Want to get your taxes done?"))) 
else 
  Output(V(Concat("",@FIRST_NAME,", want to get your taxes done?"))) 
endif
]%%

What if the first name has a dash in it?

"Mike-Paul"

The data extension has that exact name in the first name column but displays in an email like Mike-paul

How do we ensure the P remains capital?

3

You'll need to use the BuildRowsetFromString function.

You can capitalize on this code I've used in a similar use case and adapt it to your data model:

SET @properCaseFirstName = ProperCase(@firstname)

IF indexOf(@firstname, '-') > 0 THEN 
 Set @rowsFirstName = BuildRowsetFromString(@firstname,"-")
 Set @row1 = Row(@rowsFirstName, 1)
 Set @firstPart_FirstName = Field(@row1,1)
 Set @row2 = Row(@rowsFirstName, 2)
 Set @secondPart_FirstName = Field(@row2,1)
 SET @properCaseFirstName = CONCAT(ProperCase(@firstPart_FirstName),CONCAT('-',ProperCase(@secondPart_FirstName)))
ENDIF

Reference:

BuildRowSetFromString

| improve this answer | |
2

I am gonna be honest, this sounds like something that should be handled before it comes to you. This is a 'bad data issue' more than something that should be handled at output.

That being said, I know there are many times when that is not an option and you need to polish the turd you are given. Even pigs deserve lipstick at times.

Basically there is no specific solve all option for this situation, but you can create sort of 'business rules' to handle this. For example the below adds in capability around what you mentioned, but depending on other variables, this could have exceptions or cause other issues as well.

%%[ 
SET @FIRST_NAME = Replace(AttributeValue("FIRST_NAME"),"-"," - ")
if(length(@FIRST_NAME) > 2 then 
  /* Capitalize */ 
  SET @FIRST_NAME = Replace(ProperCase(@FIRST_NAME)," - ", "-") 
  Output(V(Concat("",@FIRST_NAME,", want to get your taxes done?"))) 
else /* All Caps */ 
  SET @FIRST_NAME = Uppercase(@FIRST_NAME) 
  Output(V(Concat("Want to get your taxes done?"))) 
endif 
]%% 

I combined some of your code together to reduce the size. Basically what I did to solve for your issue is do a replace on the name that will change mike-paul into mike - paul which will then, via Propercase, output Mike - Paul. Which is then returned to Mike-Paul via the second replace inside your IF statement.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.