Hi,
we are storing the history of interesting moments in a Text Field, similarly to the approach explained by Dan Stevens here. We also track the number of those records (interesting moments) in a separate Score field. So, when an interesting moment is created, it gets written in a Text field, each in a separate line, and the Score goes up for 1. To separate entries into different lines, we use this trick by Sanford.
Now, we would like to include some of the history of these interesting moments in alerts for our team, but only last 5 entries. As a non-programmer, I checked the documentation for Velocity, and got an idea for the following "pseudo-code" (sorry :):
if ScoreField is 5 or less
just output the whole content of the Text field
else
foreach (i in [1..5])
print line #i
But I am not so sure this will actually work, especially the counting of lines - because, I think, they are not really an array of values, just text - and its not possible to just iterate over them. Thus I would appreciate if someone can comment if the approach makes sense or not. And if not, any advice on on how to do it would be appreciated!
Thanks!
;m
Solved! Go to Solution.
Split, set the max # of lines and then output up to that max:
#set( $lines = $lead.testTextArea01.split("\n") )
#set( $MAX_DISPLAY_LINES = 5 )
#foreach( $lineNum in [1..$math.min($MAX_DISPLAY_LINES, $lines.size())] )
${lines[$foreach.index]}<br>
#end
Split, set the max # of lines and then output up to that max:
#set( $lines = $lead.testTextArea01.split("\n") )
#set( $MAX_DISPLAY_LINES = 5 )
#foreach( $lineNum in [1..$math.min($MAX_DISPLAY_LINES, $lines.size())] )
${lines[$foreach.index]}<br>
#end
Thanks, will give it a try!
Works great! Thanks, Sanford. Take care!