how to capture the latest comment in email notification

immanuel1
Mega Contributor

Hi Everyone,

In the email notification getting all the comments from initial on wards, but i need only the latest additional comment in the chain.

Please give some solution to capture the latest comment.

Thanks In Advance,

Immanuel

5 REPLIES 5

Karthik Reddy T
Kilo Sage

Hello Immanuel,



you need to use below script to get the latest journal entry from comments field.


current.comments.getJournalEntry(1);



only last additional comment in notification


Karthik Reddy T.
ServiceNow Commnunity MVP -2018 class.

Harsh Vardhan
Giga Patron

with out script you can do that.



2 Restrict the Number of Entries Sent in a Notification

Administrators can control the number of journal entries notifications include with the following system property.


PropertyLabelDescription
glide.email.journal.linesNumber of journal entries (Additional comments, Work notes, etc.) included in email notifications (-1 means all).Specifies the number of entries from a journal field (such as Additional comments and Work notes) included in email notifications. A value of -1 includes all journal entries.
  • Type: integer
  • Default value: 3
  • Location: System Properties > Email


http://wiki.servicenow.com/index.php?title=Using_Journal_Fields#Restrict_the_Number_of_Entries_Sent_...




Most recent 'comment' in notification


Hi ,




If we updated any comment the activity log capturing all the previous comments also.


i need to capture the latest comment in the activity log. how to do this?


have you tried with above solution.



3.27 getJournalEntry(int)

Gets either the most recent journal entry or all journal entries.


Parameters: -1: get all journal entries, 1: get the most recent journal entry.


3.27.1 Output Fields

Returns: (Sting) For the most recent entry, returns a sting that contains the field label, timestamp, and user display name of the journal entry. For all journal entries, returns the same information for all journal entries ever entered as a single string with each entry delimited by "\n\n".


3.27.2 Example

var notes = current.work_notes.getJournalEntry(-1); //gets all journal entries as a string where each entry is delimited by '\n\n' var na = notes.split("\n\n");                                             //stores each entry into an array of strings   for (var i = 0; i < na.length; i++) gs.print(na[i]);



also with properties it will work.