Customizing dynamic variables on Subject Line

Avatar

Avatar

andreab24032044

Avatar

andreab24032044

andreab24032044

07-05-2018

Greetings community,

I am working with an email campaign, where the First Name variable is pulled from a data extension. Now, that is not the problem.

The issue at hand is that, some of these names are all capitalized, and others can be all lower case.

I have tried doing something like <% targetData.FirstName.toUpperCase(); %> but all that does is to return an empty string.

Does anyone know a work around it?

Many thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

andreab24032044

Avatar

andreab24032044

andreab24032044

08-05-2018

Hello marcel.gent.86,

Unfortunately I was unable to get both suggestions to work on my end.

However, after some more research, i found the following to work great on my end:

<%

var name = targetData.FIRST_NAME;

name = name. toLowerCase().replace(/\b[a-z]/g, function(e) {
  
return e.toUpperCase();
});

%>

<%=name%>, Best email ever!

Before

before.JPG

After

after.JPG

Answers (2)

Answers (2)

Avatar

Avatar

MarcelSzimonisz

MVP

Avatar

MarcelSzimonisz

MVP

MarcelSzimonisz
MVP

08-05-2018

Hello andreab24032044​,

you need to print it by <%=

<%= recipient.firstName.toUpperCase()%>

<%= and also do not use ; when printing variable

<%= recipient.firstName.toUpperCase();%>

Will throw an error.

Do you need to capitalize just the first letter? If yes then you can use something similar:

<%= (recipient.firstName.length>3) ?  recipient.firstName.charAt(0).toUpperCase() + recipient.firstName.slice(1) : "" %>

Marcel

Avatar

Avatar

MarcelSzimonisz

MVP

Avatar

MarcelSzimonisz

MVP

MarcelSzimonisz
MVP

08-05-2018

I do not understand. It is almost the  same thing but done differently

Marcel