Velocity Script token to set max length - display first 50 characters | Community
Skip to main content
Level 2
April 10, 2019
Question

Velocity Script token to set max length - display first 50 characters

  • April 10, 2019
  • 2 replies
  • 1658 views

I am hoping someone can help me with this. I am trying to use a token in an email where the field value character count can be anywhere between 50-100. This variation of character count is messing up the formatting of the email. Is it possible to use a velocity script to set the max length and then if the value exceeds the max value – show the first 50 characters and an ellipsis?

Product Name (Actual Value): LIFE SAVERS Wint-O-Green Individually Wrapped Breath Mints, 3 lb. Stand-up Bag (Actual Value)

Product Name (Displayed Value): LIFE SAVERS Wint-O-Green Individually…

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

2 replies

SanfordWhiteman
Level 10
April 10, 2019

#set( $Class = $context.class )

#set( $WordUtils = $Class.forName("org.apache.commons.lang.WordUtils") )

${WordUtils.abbreviate($lead.truncateableValue,50,50,"...")}

SanfordWhiteman
Level 10
April 12, 2019

@Eric Rosenberg please return to the thread and check responses.