Hi,
What's the best way to use the syntax for Smartcase (capitalization of the first letter of a name) for the personalization in Adobe Campaign Classic, when your personalization syntax is <%= rtEvent.ctx.firstName.@value %>
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
I think the confusing thing here is the person answering previously is making the assumption that you have a custom personalisation block on your instance called "toSmartCase" which is likely not available on your installation.
What they have done is created a personalisation block external to the template called "toSmartCase" which contains some custom javascript function .toSmartCase(). They are then asking you to include this and it does not exist.
I have 2 solutions for you and you can test this in any template MKT or RT.
<!-- This section is just to fake up the rtEvent variable as you have documented in your support ticket -->
<%
var rtEvent = <rtEvent><ctx><firstName value="paul sheppard"/></ctx></rtEvent>;
%>
<!--
This section is some javascript to add a <string>.toProperCase() function to all strings in the template.
You can exteneralise this if required, but you would have to add it to a personalition block, and then include it.
I would suggestion for now just to add it to your template.
-->
<%
String.prototype.toProperCase = function() {
var words = this.split(' ');
var results = [];
for (var i = 0; i < words.length; i++) {
var letter = words[i].charAt(0).toUpperCase();
results.push(letter + words[i].slice(1));
}
return results.join(' ');
};
%>
<!-- This first one is a simple version to captialise the first letter of a variable and does not need the toProperCase() function, if this is enough for you, then just use this.-->
<p><%= rtEvent.ctx.firstName.@value.substring(0,1).toUpperCase()+rtEvent.ctx.firstName.@value.substring(1,100).toLowerCase() %></p>
<!-- This second example use the previous toProperCase function and will smart case the whole string -->
<p><%= rtEvent.ctx.firstName.@value.toProperCase() %></p>
Hello @kkoor ,
You can use the personalization block and call the toSmartCase function in personalization block and pass the event variable to function then print the value in template.
Thanks,
Manoj
Hi Manoj, Thank you for your feedback, but when I use personalization blocks, I can't see where to retrieve the functions. Were you thinking of this: <%= .toSmartCase() + rtEvent.ctx.firstName.@value %> (note it's for transactional (in commercial campaigns I see the functions, but not in transactional)
Or do I need to add it in a script??
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Hi,
I think the confusing thing here is the person answering previously is making the assumption that you have a custom personalisation block on your instance called "toSmartCase" which is likely not available on your installation.
What they have done is created a personalisation block external to the template called "toSmartCase" which contains some custom javascript function .toSmartCase(). They are then asking you to include this and it does not exist.
I have 2 solutions for you and you can test this in any template MKT or RT.
<!-- This section is just to fake up the rtEvent variable as you have documented in your support ticket -->
<%
var rtEvent = <rtEvent><ctx><firstName value="paul sheppard"/></ctx></rtEvent>;
%>
<!--
This section is some javascript to add a <string>.toProperCase() function to all strings in the template.
You can exteneralise this if required, but you would have to add it to a personalition block, and then include it.
I would suggestion for now just to add it to your template.
-->
<%
String.prototype.toProperCase = function() {
var words = this.split(' ');
var results = [];
for (var i = 0; i < words.length; i++) {
var letter = words[i].charAt(0).toUpperCase();
results.push(letter + words[i].slice(1));
}
return results.join(' ');
};
%>
<!-- This first one is a simple version to captialise the first letter of a variable and does not need the toProperCase() function, if this is enough for you, then just use this.-->
<p><%= rtEvent.ctx.firstName.@value.substring(0,1).toUpperCase()+rtEvent.ctx.firstName.@value.substring(1,100).toLowerCase() %></p>
<!-- This second example use the previous toProperCase function and will smart case the whole string -->
<p><%= rtEvent.ctx.firstName.@value.toProperCase() %></p>
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Likes
Replies