Creating a New Line Program Token to Organize a History Field

Nate_Oosterhous
Level 7
Hello Everyone!

I really need your help on this one.  

Question: Does anyone know how to create a program token that would create a new line if added to inbetween tokens.  

I am looking to format a history field like the example below:

Filled out Form on: 2015-03-10 13:00:00  Form Comments: This is the comments from the 3rd form fill out.

Filled out Form on: 2015-02-10 12:00:00  Form Comments: This is the comments from the 2nd form fill out.

Filled out Form on: 2015-01-10 11:00:00  Form Comments: This is the comments from the 1st form fill out.

Right now it looks all mashed together like this:

Filled out Form on: 2015-03-10 13:00:00  Form Comments: This is the comments from the 3rd form fill out.
Filled out Form on: 2015-02-10 12:00:00  Form Comments: This is the comments from the 2nd form fill out.Filled out Form on: 2015-01-10 11:00:00  Form Comments: This is the comments from the 1st form fill out.

Below is my Flow Action: 


0EM50000000SyWM.jpg

I am looking to figure out some way to use a program token in the default choice of this Change Data Value Flow.  Right now I have a program token in the place where I want it but I can't figure out how to get that to represent two new lines.

 
Tags (1)
47 REPLIES 47
Anonymous
Not applicable

I am having same challenge.

In the Marketo Flow Action logic the Attribute LOV only displays Lead attributes ( lead fields).

If you create a program token you will not find in the Lead attribute list.

Program Tokens are only available in Digital Assets  (EMail or LP) for now.

Nate_Oosterhous
Level 7
Thanks Josh,

I will continue to research.  I haven't found anything yet that works.
Josh_Hill13
Level 10 - Champion Alumni

oh so you want a new line in a field.
 

Do a quick search. there are some threads on this. It is not easy.

Anonymous
Not applicable

I've been searching and reading for months for a solution to this. If you have any links to info, please share.

Thanks!

SanfordWhiteman
Level 10 - Community Moderator

I've got a method that works.  It's delicate and it's probably best if I walk you through it remotely.  DM me if you want.

Example audit trail field:

pastedImage_0.png

SanfordWhiteman
Level 10 - Community Moderator
Dan_Stevens_
Level 10 - Champion Alumni

Sanford Whiteman, your solution works great when the values need to be stored like this in a history field.  The issue arises when we use that history field as a token in an email.  For example, here's the value in the lead record:

2017-07-24 13:48:10: Visited 5 or more web pages in 1 day

2017-07-24 12:14:09: Filled Out Contact Us Form as Potential Customer (Overseas Adventure Travel): Contact Us 2.0 (USA) on www.avanade.com/en-us/contact

But when we use {{lead.Interesting Moment History}} in an email alert, it appears as follows (with no line breaks):

pastedImage_1.png

Any ideas on how to have this render properly in an email?

SanfordWhiteman
Level 10 - Community Moderator

${display.br($lead.InterestingMomentHistory)}

in a Velocity token.

Different output contexts, different line break sequences....

Dan_Stevens_
Level 10 - Champion Alumni

That doesn't seem to work.  Here's the exact velocity token - called {{my.IM History}} that I'm using:

${display.br(${lead.avanadeInterestingMomentHistory})}

For your reference, the history field is built as follows:

{{lead.Last Interesting Moment Date}}: {{lead.Last Interesting Moment Desc}}{{my.line-break}}{{lead.Avanade Interesting Moment History}}

where "my.line-break" is using the approach you describe in this post.

SanfordWhiteman
Level 10 - Community Moderator

What kind of "doesn't work" -- what's the output HTML?

$display.br() is a built-in method to replace true newlines with HTML <br />, so it's perfect for this. (We could write the replacement in VTL but shouldn't need to.)

Dan_Stevens_
Level 10 - Champion Alumni

Here's the token:

pastedImage_1.png

Here's how the token is used in the email alert:

pastedImage_4.png

And here's how it renders in an email (instead of pulling the history value from the lead record, it's including the actual script):

pastedImage_3.png

SanfordWhiteman
Level 10 - Community Moderator

The field is checked off in the tree on the right-hand-side of Script Editor?

Dan_Stevens_
Level 10 - Champion Alumni

It was when I initially created it (since I checked it; and dragged the field into onto the canvas) - but after checking now, it was not checked.  So repeated the process again (confirmed it's now checked, even after saving, closing and re-editing the script).  Here's the result:

pastedImage_0.png

Do you think I need to use two line-break tokens in the history field, instead of one?

Here's the value as it appears in the database:

pastedImage_0.png

SanfordWhiteman
Level 10 - Community Moderator

Nah, only need one. br() changes every single linebreak. What about if you manually hit enter in the field and add another line? That'll help us narrow down.

Dan_Stevens_
Level 10 - Champion Alumni

Nope, same result as above.  Here's the new value in the DB:

2017-07-24 12:58:39: Promoted to MQL after attending an Avanade Event: 2017-06-14 NA USA EV-ML Retail Executive Summit-ERP TracyA

2017-07-24 12:48:44: Attended an Avanade Event: 2017-06-14 NA USA EV-ML Retail Executive Summit-ERP TracyA

2017-07-24 12:43:47: Registered for an Avanade Event: 2017-06-14 NA USA EV-ML Retail Executive Summit-ERP TracyA

SanfordWhiteman
Level 10 - Community Moderator

Dan, I can't repro this.

Here's text field with newlines:

pastedImage_0.png

The Velocity token to change the true newlines to <BR>s:

pastedImage_2.png

And the output:

pastedImage_1.png

Dan_Stevens_
Level 10 - Champion Alumni

I even tried another technique that you authored here: http://blog.teknkl.com/newlines-to-brs-in-velocity/

pastedImage_2.png

And still no luck.  I also tried using a bare-bones HTML email.  This is driving me crazy.

SanfordWhiteman
Level 10 - Community Moderator

So bizarre! What would Velocity be doing here if ​not ​altering the output... and not throwing an error?

It's as if your fields don't contain \n.

Can you try another replacement, as a sanity check?

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

Dan_Stevens_
Level 10 - Champion Alumni

Now we're getting somewhere.  Here's the email - where everything has been replaced with <BR> - the gray area is me highlighting them with my mouse:

pastedImage_0.png

And here's the code to prove it:

pastedImage_0.png

But I have no periods "." in that field.  What was replaced with all of those <br>'s?  Or did this replace every character (including the 2 line breaks) with a <br>?  There are are 17 characters (include the breaks), and 17 <br>s here.

SanfordWhiteman
Level 10 - Community Moderator

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>")}