Notification - Most recent comment

MStritt
Tera Guru

I'm creating a notification. The notification will be sent to the Assigned To person whenever the customer makes an update to the case via Portal. I would like to include in the email, the most recent comment made by the customer that triggers the notification. I can add additional comments (comments) in the email, but it includes ALL additional comments on the case. Is it possible to include just the most recent comment\update made by the customer?

6 REPLIES 6

Saurav11
Kilo Patron
Kilo Patron

Hello

Use notification email script

To get the latest comment type current.comments.getJournalEntry(1);

Then call the email script in the notification

Please mark answer correct/helpful based on impact

Jaspal Singh
Mega Patron
Mega Patron

Is this for all notifications sent across from ServiceNow for comments? If so, look for 

System Properties >> Mail Properties

find_real_file.png

 

Change the number to 1. It would mean platform wide any notification sent for comments.

 

If you want it to be specific for a table you need mail script & use current.comments.getJournalEntry(1); & then use the mail script in notifications.

No. This is just a notification on the Case table for specific conditions. It will be sent to the Assigned To on the case.

find_real_file.png

In the body of the email/notification, I want to include the most recent update (additional comments) that was just made to the case by the customer.

find_real_file.png

Follow below

1. Create a mail script by navigating to System Notification >> Email >> Notification mail script

2. Name it getlatestcommentsonly with script as below.

(function runMailScript(current, template, email, email_action, event) {

    var latestcommentsare = current.comments.getJournalEntry(1);
    template.print(latestcommentsare);

})(current, template, email, email_action, event);

3. Go to notification & add below just after the line Short description: ${short_description}

Comments: ${mail_script:getlatestcommentsonly}