Re: Creating a New Line Program Token to Organize a History Field

SanfordWhiteman
Level 10 - Community Moderator

Re: Creating a New Line Program Token to Organize a History Field

The dot is regular expression syntax for "any character," so the idea was to see what you saw.

Now try this:

${lead.Lead_Notes.replaceAll("\r","<BR>")} 

Dan_Stevens_
Level 10 - Champion Alumni

Re: Creating a New Line Program Token to Organize a History Field

That did not work:

Which is what's really bizarre since I tried three different types of line-breaks in my tests:

  1. Your technique (the focal point of this post)
  2. Using the ENTER key
  3. Using SHIFT-ENTER

Just for the heck of it, I tried ${lead.Lead_Notes.replaceAll("e","<BR>")} and got this:

pastedImage_0.png

So the issue is clearly with the hidden line-break character.

SanfordWhiteman
Level 10 - Community Moderator

Re: Creating a New Line Program Token to Organize a History Field

Yeah, the question is what on Earth could that character be in your instance?

The {{token}} expressly contains a single \n.

We've now tried Velocity replacement expressions on \r\n, \n, and just \r!

Try this and post the output:

#foreach( $char in $lead.Lead_Notes.toCharArray() )

$lead.Lead_Notes.codePointAt($math.sub($velocityCount,1))<br>

#end

Dan_Stevens_
Level 10 - Champion Alumni

Re: Creating a New Line Program Token to Organize a History Field

Here's the output:

108
105
110
101
49
32
108
105
110
101
50
32
108
105
110
101
51

SanfordWhiteman
Level 10 - Community Moderator

Re: Creating a New Line Program Token to Organize a History Field

That shows that the newlines are spaces (char 32) in your Velocity context! What the?!?

And yet the newlines are preserved in the UI when you refresh the page?

Dan_Stevens_
Level 10 - Champion Alumni

Re: Creating a New Line Program Token to Organize a History Field

You mean here?  If so, then yes.  These were all entered as:

line1<ENTER>

line2<ENTER>

line3

pastedImage_0.png

SanfordWhiteman
Level 10 - Community Moderator

Re: Creating a New Line Program Token to Organize a History Field

Maybe we should get on a call and figure this out. Send me an email...

Dan_Stevens_
Level 10 - Champion Alumni

Re: Creating a New Line Program Token to Organize a History Field

Sandy, thanks for taken the call with me yesterday.  I went ahead and cloned the working alert email that gets sent as part of a trigger campaign.  That email failed to render as well.  The commonality in all of this testing is that it seems to work with trigger campaigns, but not batch campaigns (all my tests were done using batch campaigns).  Are you aware of any limitations in using specific velocity methods with batch campaigns (similar to how you cannot use tokens in the "send alert" flow step as I mentioned here: Sales Alert Batch Campaign ?

SanfordWhiteman
Level 10 - Community Moderator

Re: Creating a New Line Program Token to Organize a History Field

No man, that's crazy. Esp. because it's the field value itself that seems to be getting munged in the batch campaign and not getting changed in the trigger.

Dan_Stevens_
Level 10 - Champion Alumni

Re: Creating a New Line Program Token to Organize a History Field

That very well may be the case as well.  But how do we get Support to determine if that's what's happening?