Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Include only latest 'Comments' Update in Notification

Josh80
Tera Expert

Hello All

I know this is a common thing but I have tried everything I could find on the Wiki.

Requirement: per TABLE, as needed, limit comments in 'Update Notification' emails to only the most recent journal entry.

I could change the system setting as found here     Using Journal Fields - ServiceNow Wiki

However, this is a Global setting and will apply to everything...we require a bit more flexibility.

I found a helpful suggestion that would modify the Incident Events business rule and modify for 'comments changes' to:

if (current.operation() != 'insert' && current.comments.changes()) {

var cmt = current.comments.getJournalEntry(1);

gs.eventQueue("incident.commented", current, gs.getUserID(), cmt);

}

....and added ${event.parm2} into the notification's template, as shown below.

Short description: ${short_description}

Click here to view: ${URI_REF}

<hr/>

Comments:

${event.parm2}

<hr/>

<div>${mail_script:cxs_EmailSearchResults}</div>

However the result is one entry in the notification for comments that looks like a sys_id.   See attachment.

Not sure why I can't get this to work.   Any suggestions or workarounds?
Thanks

1 ACCEPTED SOLUTION

shill
Mega Sage

I use a Notification Email Script.


Scripting for Email Notifications - ServiceNow Wiki


Create the email script, then call the email script from the body of the notification with the ${mail_script:getLastComment} where you want the last comment to be located.


Here is my simple one.


find_real_file.png


View solution in original post

7 REPLIES 7

johnram
ServiceNow Employee
ServiceNow Employee

The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here: Scripting for Email Notifications




Visit http://docs.servicenow.com for the latest product documentation


I'm using this email script and getting the comments surrounded by [code] and [/code].  Anyone experience this with email scripts?

nickde
Tera Contributor

I'm having a similar issue, I am getting the date and name of person posting it in my emails too. I only want the body of the entry. Any ideas?