
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 05:56 AM - edited 12-23-2024 07:00 AM
Hello, smart folks. What am I doing wrong here, please? ...
I created a notification which looks like this:
The associated Email script looks like this:
When I use the "Preview Notification" button, and supply the record number of an HR Benefits Case, everything seems to work fine, as you can see here:
But when the email is actually sent out, I don't get any data from the "comments_and_work_notes" field or the mail script, as you can see here:
How can the Preview work, but the actual email functionality Not work?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 12:19 PM
Found the answer with help from ServiceNow tech support...
There is a ServiceNow bug around the comments_and_work_notes field. It is documented in an existing knowledge article available here:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1587782
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 06:10 AM
are you able to see the comments value in email logs?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 07:13 AM
The field "comments" works fine. And "work_notes" works fine. But comments_and_work_notes does Not.
But if you are referring to the "sent" log, the comments_and_work_notes field (and script) does not seem to be working there either:
Did I understand you correctly?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 08:41 AM
Hi @G24
Based on the image you provided, it looks like the email script is not fetching the data from the "comments_and_work_notes" field as expected.
1-Ensure that the "comments_and_work_notes" field is accessible in the context of the email notification. There might be ACLs (Access Control Lists) that restrict access to this field.
2-Make sure that the "comments_and_work_notes" field actually contains data for the record you are testing with. You can do this by checking the record directly in the ServiceNow instance.
3. Double-check the email script for any errors or issues. Ensure that the script is correctly fetching and processing the data from the "comments_and_work_notes" field.
here is the debug version of this email script
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
template.print("Mail Script START<br/>");
gs.log("Mail Script START");
var $output = current.comments_and_work_notes.getJournalEntry(3);
gs.log("Comments and Work Notes: " + $output);
template.print($output);
template.print("<br/>Mail Script END.");
gs.log("Mail Script END");
})(current, template, email, email_action, event);
Here we will debug the script and checked is our script work well.
I hope this will help you to solve this Issue
Please mark it helpful. If this solve your issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 10:28 AM - edited 12-19-2024 10:32 AM
Thanks. @Bhupender I added logging to the script as follows.
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
gs.info("GGB Mail Script START");
template.print("Mail Script START<br/>");
var sOutput = current.comments_and_work_notes.getJournalEntry(3);
gs.info("GGB Comments and Work Notes: " + sOutput);
template.print(sOutput);
gs.info("GGB Mail Script END");
template.print("<br/>Mail Script END.");
})(current, template, email, email_action, event);
When I preview the notification, I see this:
But when the notification runs as a result of a new work note getting added, I see this: