Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!
SOLVED

Customizing dynamic variables on Subject Line

Avatar

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

Avatar

Correct answer by
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

Avatar

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

Avatar

Correct answer by
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

Avatar

Community Advisor

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

Marcel