Smartcase use in Transactional messages | Community
Skip to main content
Level 2
October 26, 2020
Solved

Smartcase use in Transactional messages

  • October 26, 2020
  • 2 replies
  • 6002 views

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 %>

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by psheppar

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>

2 replies

Manoj_Kumar
Community Advisor
Community Advisor
October 26, 2020

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

Manoj     Find me on LinkedIn
kkoorAuthor
Level 2
October 26, 2020

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??

psheppar
Adobe Employee
pshepparAdobe EmployeeAccepted solution
Adobe Employee
November 18, 2020

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>

psheppar
Adobe Employee
Adobe Employee
November 19, 2020
I have just execute the above template, With the following event body and it worked as expected: <ctx> <firstName value="Paul Sheppard"/> </ctx>