How to print comments through Email Notification script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi,
I am trying to print the last comment/worknotes in a notification using email script:
pls check this
[/code]- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @gazalagrawa ,
Use the Regex script or else get the value from the "sys_journal_field" table.
If my response helped, mark it as helpful and accept the solution.
Thanks,
Teja.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @gazalagrawa,
This behavior is commonly seen with CSM Configurable Workspace, where journal entries may be stored with formatting markers such as [code] and [/code].
Since getJournalEntry(1) returns the raw journal content, those tags are included in the output.
You can remove them before printing:
var comment = current.comments.getJournalEntry(1);
comment = comment.replace(/\[code\]|\[\/code\]/g, '');
template.print('Comments: ' + comment);
If you need only the actual comment text (without timestamps, usernames, or formatting), query the sys_journal_field table and use the value field instead of getJournalEntry().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @gazalagrawa
With your code, you can use regex to remove [/code] ,[code]tag.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
49m ago
you need to use email script to remove that text
use this
var comments = cs.comments.getJournalEntry(1);
var dateRE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;
var onlyCommentsText = comments.replace(dateRE, '');
template.print('Comments '+ onlyCommentsText );
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader