Need to display all the updates on notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 04:31 AM
HI Community,
I have a requirement, when there is update happened on major incident then only last 3 updates are shown in mail but i need to show all the updates and it seems like there is oob email script called getLastThreeActivityLog is used.
script:
- Labels:
-
Major Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 04:52 AM
then use this
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
template.print('Action taken History:' + '<br/>');
var gr = new GlideRecord('sys_journal_field');
gr.orderByDesc('sys_created_on'); // show the latest and then old
gr.addQuery('element', 'actions_taken');
gr.addQuery('element_id', current.incident_alert.source_incident);
gr.query();
while (gr.next()) {
template.print(gr.value + '<br/>');
}
})(current, template, email, email_action, event);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 04:53 AM
Would you mind closing your earlier questions by marking appropriate response as correct?
Members have invested their time and efforts in helping you.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 05:08 AM
use this
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Retrieve all journal entries by passing a large number (e.g., 1000)
var activities = current.incident_alert.source_incident.actions_taken.getJournalEntry(1000);
// Split the activities into individual entries
var activityArray = activities.split("\n\n");
// Print each activity entry
template.print("<br/>");
for (var i = 0; i < activityArray.length; i++) {
template.print(activityArray[i] + "<br/>");
}
})(current, template, email, email_action, event);