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

Highlighted

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

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…

pastedImage_2.png

2 REPLIES 2
Highlighted
Level 10 - Community Moderator

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

#set( $Class = $context.class )

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

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

Highlighted
Level 10 - Community Moderator

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

Eric Rosenberg please return to the thread and check responses.