When getting a full list of comments from a notifcation mail script (i.e. .getJournalEntry(-1)) the first entry is trimmed

pierrep1
Mega Guru

Hi,

I have a mail script which get's the full list of journal entries.  It splits the comments and makes the timestamp bold btw.

If the ticket is created via an inbound email, we have the additional comments populated with the body of the email. This is so that when there are back and forth emails (via adding 'commented' notification) the original email is on the thread.

Now Service now if trimming the comment of the email body after the very first line.  This does not happen if the ticket is created manually

Does anyone know why this could be happening?

Script and screen shots below:

var notes = current.comments.getJournalEntry(-1);
var na = notes.split("\n\n");

for (var i = 1; i < na.length; i++){
var comment = na[i].split("(Additional comments)");
if(comment[1].trim()!= undefined){
comment[0] = comment[0].replace("[code]", "");
comment[0] = comment[0].replace("[/code]", "");
comment[1] = comment[1].replace("[code]", "");
comment[1] = comment[1].replace("[/code]", "");
template.print("<b>"+ comment[0] + "(Additional comments)" +"</b>");
template.print("<br><br>"+ comment[1]+ "<br><br>");
}
}

 

(I can't post a screen shot of the email due to confidentiality, but it is a large email thread, but I will compose something of the same syntax)

Thank you Paul

much appreciated

Regards

Tom

From:paul@example.com

Sent: 2/12/2018

To:Tom@example.com

Hi Tom,

Here is it.

Regards,

Paul

And a screen shot of what the notification looks like (ignore the result part):

find_real_file.png

5 REPLIES 5

Rafael,

Thank you so much for your suggestions. I was able to make the comments an unordered with a couple of tweaks.

 

template.print("<div><ul>");
while (journalEntry.next()) {
// Build comment layout
template.print("<li><hr style='height: 1px; border: none; color: #f1f1f1; background-color: #f1f1f1'; ><strong>" + journalEntry.sys_created_on.getDisplayValue() + " " + journalEntry.sys_created_by + "</strong><br><span style='word-wrap:break-word;display:block;'>"+journalEntry.value+"</span></li>");
}
template.print("</ul></div>");