- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2022 08:07 AM
I'm creating a notification on the Case table, that will send a notification when a case has been updated by the customer. In the 'What it will contain' portion of the notification, I'd like to include the most recent update made by the customer. Currently, I've added the 'Additional comments' variable, but it displays all additional comments in the case. I only want to show the most recent additional comment by the customer, that triggered the notification.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2022 08:37 AM
Hello MStritt,
You need to use email script to achieve this requirement.
Please follow the below steps.
1. Create a Email notification script and add the below script.
Lets assume the name of this script is : case_email_notification
var latestCom = new GlideRecord('sys_journal_field'); // Sys Journal is the table which contains all work notes and comments
latestCom.addEncodedQuery('element_id=' + current.sys_id); //no need to change this
latestCom.orderByDesc('sys_created_on');
latestCom.setLimit(1); // this will ensure to pick the latest comment made on the case
latestCom.query();
if (latestCom.next()) {
template.print('<p><font size="6" color="#808080" face="helvetica">');
template.print(latestCom.value); // printing the latest comment. no need to check this field until unless you modified the value field in Sys Journal table(Which I doubt)
template.print('</font></p>');
2. Open your notification and add this Email notification script in the message HTML like below:
${mail_script:case_email_notification} .
It will fix your issue. Check and let me know if it fixed your issue or not.
Thanks,
Bhavani.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2022 11:16 PM
@MStritt I'm surprised you didn't accept my solution, Basically you don't need to gliderecord journal table, you can simply do like below. Can you accept my solution as well ?
Email script
(function runMailScript(current, template, email, email_action, event) {
template.print('Comments '+current.comments.getJournalEntry(1));
})(current, template, email, email_action, event);
And in notification 'What will contain' just call script
${mail_script:test123}
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2022 08:16 AM
Hello,
Create email script then call in Notification, this is very simple, here is the example
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2022 11:16 PM
@MStritt I'm surprised you didn't accept my solution, Basically you don't need to gliderecord journal table, you can simply do like below. Can you accept my solution as well ?
Email script
(function runMailScript(current, template, email, email_action, event) {
template.print('Comments '+current.comments.getJournalEntry(1));
})(current, template, email, email_action, event);
And in notification 'What will contain' just call script
${mail_script:test123}
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2022 08:37 AM
Hello MStritt,
You need to use email script to achieve this requirement.
Please follow the below steps.
1. Create a Email notification script and add the below script.
Lets assume the name of this script is : case_email_notification
var latestCom = new GlideRecord('sys_journal_field'); // Sys Journal is the table which contains all work notes and comments
latestCom.addEncodedQuery('element_id=' + current.sys_id); //no need to change this
latestCom.orderByDesc('sys_created_on');
latestCom.setLimit(1); // this will ensure to pick the latest comment made on the case
latestCom.query();
if (latestCom.next()) {
template.print('<p><font size="6" color="#808080" face="helvetica">');
template.print(latestCom.value); // printing the latest comment. no need to check this field until unless you modified the value field in Sys Journal table(Which I doubt)
template.print('</font></p>');
2. Open your notification and add this Email notification script in the message HTML like below:
${mail_script:case_email_notification} .
It will fix your issue. Check and let me know if it fixed your issue or not.
Thanks,
Bhavani.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2022 07:04 AM
Can I ask an additional question? I've noticed that I'm getting an email notification every time the case is updated. I only want one notification when the customer updates the case for the most recent update. I have 'Updated' selected in the 'When to send' part of the notification. I believe that's why. Should I uncheck 'Updated' and check 'Inserted'?