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

Jorge Andre Per
Kilo Expert

I think you are doing it right, except that you want the value of 'cmt' not 'cmt' itself so I would suggest gs.eventQueue("incident.commented", current, gs.getUserID(), cmt.value);


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


Hello Steven



I've tried this....but same results.   It displays the sys_id of the last entry, not the actual entry itself.



Any suggestions?


Thanks!


Strike that - got it to work.   Thank you Steven!