Email Notification Showing Last Comment with <Code> Tag

Tigermomdr
Tera Contributor

We want to just display the last journal entry in the email notification, but it is printing <Code> tag in the email:

Tigermomdr_0-1705715900250.png

Here is the OOTB show_only_last_comment email script:

Tigermomdr_1-1705715962446.png

And this is our email body:

Tigermomdr_2-1705716144859.png

There is no issue if we display all comments using ${comment}. Any suggestion on how I can get around this would be greatly appreciated.

1 REPLY 1

Maik Skoddow
Tera Patron
Tera Patron

Hi @Tigermomdr 

in ServiceNow, the [code] and [/code] placeholders are wrapping tags to carry HTML in comments. You can remove them without loosing any functionality:

var comment = current.comments.getJournalEntry(1).split('\n')[1].replaceAll(/\[code\]|\[\/code\]/g,"");

Maik