- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 02:43 AM
I’m working on a requirement where we need to send an email notification from a task (Change) that includes the latest 3 work notes in the email body.
Has anyone implemented a similar solution? I’m looking for the best approach to achieve this—whether through a notification template, scripted email, or email script.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 03:16 AM - edited 06-20-2025 03:21 AM
Hi @KARUNK,
By default, glide.email.journal.lines is set to 3 but that includes Additional Comments too.
Use this email script to retrieve last 3 lines of Worknotes.
Note: This will work on Record insert or update.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var work_note = new GlideRecord("sys_journal_field");
work_note.addEncodedQuery("element_id=" + current.sys_id + "^element=work_notes");
work_note.orderByDesc('sys_created_on');
work_note.setLimit(3);
work_note.query();
while (work_note.next()) {
var user = new GlideRecord("sys_user");
user.addQuery("email", work_note.sys_created_by);
user.query();
if (user.next()) {
template.print('<hr>');
template.print('<div style="display: flex; justify-content: space-between; align-items: center;">');
template.print('<span><b>' + work_note.sys_created_on + ' - ' + user.name + '</b></span>');
template.print('<span>(Work Notes (Internal))</span>');
template.print('</div>' + work_note.value + '<br>');
}
}
})(current, template, email, email_action, event);
Regards,
Ehab Pilloor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 02:46 AM
Hi @KARUNK
Change this property:
but it will be a global change.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 03:18 AM
I’m specifically looking to include only the latest 3 work notes from Change Requests (change_request) in the email notification.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 03:30 AM
Hi @KARUNK
In that case, you need to create an email script as suggested by @Ehab Pilloor or @Ankur Bawiskar, and then you can do it in a change request specific to your needs.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 03:07 AM
Solved: Get latest 3 work notes in email - ServiceNow Community-
You can follow find the solution in the above post. Thank you.