Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Customizing dynamic variables on Subject Line

andreab24032044
Level 2
Level 2

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

1 Accepted Solution
andreab24032044
Correct answer by
Level 2
Level 2

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

View solution in original post

3 Replies
Marcel_Szimonisz
Community Advisor
Community Advisor

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

andreab24032044
Correct answer by
Level 2
Level 2

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

View solution in original post

Marcel_Szimonisz
Community Advisor
Community Advisor

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

Marcel