display last additional comment in notification

ofekg
Tera Contributor

hwy'
needs help to write email script to retrieve the last additional comment in the specific request item . 

3 REPLIES 3

Anurag Tripathi
Mega Patron
Mega Patron

Tai Vu
Kilo Patron
Kilo Patron

Hi @ofekg 

Have you tried this method below? 

getJournalEntry(Number mostRecent)

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

Parameters
Name Type Description
mostRecentNumberIf 1, returns the most recent entry. If -1, returns all journal entries.
Returns
Type Description
String

For the most recent entry, returns a string 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".

 

Example

 

//get the most recent entry
var comment = current.comments.getJournalEntry(1); 

 

 

Cheers,

Tai Vu

 

Runjay Patel
Giga Sage

Hi @ofekg ,

 

Follow below steps to get comments printed in your notification.

  1. Create notification and call mail script. Syntax is: ${mail_script:comments} where comments is mail script name.
  2. Use below script in email script to get it printed in your email body.

 

template.print('<b>Comments:</b> ' + current.comments.getJournalEntry(1) + '<br><br>');

 

  • RunjayPatel_0-1732181981823.png

     

  • RunjayPatel_1-1732182032024.png

     

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------