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
Solved! Go to Solution.
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
After
Views
Replies
Total Likes
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
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
After
Views
Replies
Total Likes
I do not understand. It is almost the same thing but done differently
Marcel
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies