Email Script Token Shows Token as Text | Community
Skip to main content
New Participant
January 11, 2022
Solved

Email Script Token Shows Token as Text

  • January 11, 2022
  • 1 reply
  • 3943 views

I'm sure this is a simple solution but, being as new to Velocity as I am (very), I have no idea how to resolve it.

 

I created my script (below) and previewed the email. It results in nothing. If I create a standalone display of one of the in-script tokens, it results in the token as text. For example, having it display "$eventCount" results in the literal text of "$eventCount".

 

Am I missing something?

 

#set($originalLength = $lead.Field-1.length()) #set($replacedLength = $lead.Field-1.replace(";","").length()) #set($eventCount = $originalLength - $replacedLength) #if($eventCount == 1) <p>You succesfully registered for a training class. If you are attending virtually, you will recieve the link to join via this email address the day before training begins. If you have any questions please reach out to Person at <a href="mailto:person@emailaddress.com" target="_blank"> person@emailaddress.com</a>.</p> #else <p>You succesfully registered for $eventCount Trend Micro training classes. If you are attending virtually, you will recieve the links to join via this email address the day before training begins. If you have any questions please reach out to Person at <a href="mailto: person@emailaddress.com" target="_blank"> person@emailaddress.com</a>.</p> #end <ul> #if ($lead.Field-1.matches(".*Product1.*")) <li><strong>Product 1 Certified Professional</strong> DATE<br /><a href="LINK.COM" target="_blank">Add to Calendar&nbsp;&rarr;</a></li> #end #if ($lead.Field-1.matches(".*Product2.*")) <li><strong>Product 2 Certified Professional</strong> DATE<br /><a href="LINK.COM" target="_blank">Add to Calendar&nbsp;&rarr;</a></li> #end #if ($lead.Field-1.matches(".*Product3.*")) <li><strong>Product 3 Certified Professional</strong> DATE<br /><a href="LINK.COM" target="_blank">Add to Calendar&nbsp;&rarr;</a></li> #end </ul>
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 SanfordWhiteman

Let's step back. What business logic are you trying to implement here? And field-1 is not a valid dot-property name; Marketo will never generate such a name.

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
January 11, 2022

Let's step back. What business logic are you trying to implement here? And field-1 is not a valid dot-property name; Marketo will never generate such a name.

New Participant
January 11, 2022

Ah, you're right. Not my smartest moment. I typed the field names with dashes and underscores as if I were within the email itself instead of as alphanumeric only. Thanks for the catch, Sanford!

 

Regarding the use case, it's to change a confirmation email's copy based on which events (1 or more) a recipient signs up for as opposed to create a permutation of confirmation emails based on all the combinations of event registrations.

SanfordWhiteman
New Participant
January 12, 2022

Still not seeing the full story. Pull back a bit. What is exact format of the field you’re doing that weird replace/regex on? Surely there’s a better way.