force template.print line break

smithcorey
Giga Contributor

I am sending an email notification when incident is commented.

No big deal, right ?

In the comment field, I typed a, then hit Enter, typed b, then hit Enter, typed c, then hit Enter.

The notification has ${comments} in it.

This works great, but the sys_created_by and sys_created_on are added. We do not want these two fields.

comment 1.PNG

So I wrote a mail script to strip off the timestamp and user name, but now the comments are put into a string that I can not figure out how to force a line break after each comment.

this is what my script produces, removing the sys_created fields, but loses the line breaks.

find_real_file.png

mail script.PNG

Any ideas ?????

1 ACCEPTED SOLUTION

This is now working, thanks to you and your assistance !



Header is being stripped and comments in notification are in "list format".



The final thing I had to do was check the Newlines to HTML box.



find_real_file.png


View solution in original post

4 REPLIES 4

Kalaiarasan Pus
Giga Sage

Try


var notes = current.comments.getJournalEntry(-1);


  var na = notes.split("\n\n");


  for (var i = 0; i < na.length; i++)


  {


  var subNotes = na[i].split("\n");


  for (var j = 1; j < subNotes.length; j++)


  {


template.print(subNotes[j].toString());


  }



  }


Deeply appreciate your time and your script.



The script worked beautifully stripping out the "header"   = Customer Visible Comments


Thank you.



Unfortunately, the comments are not is a list format in the Notification as they are in the Comment field.


That continues to be my challenge.



comment field


find_real_file.png



and same comments in the notification


find_real_file.png


Can you add a '\n'?



template.print(subNotes[j].toString()+'\n');


This is now working, thanks to you and your assistance !



Header is being stripped and comments in notification are in "list format".



The final thing I had to do was check the Newlines to HTML box.



find_real_file.png