Notification, how to take last comment or work note

ankit_gupta1
Tera Expert

My requirement is to take last comment or work note ,which one last updated either additional comment or worknotes . how to do that.

ctomasi

16 REPLIES 16

Alikutty A
Tera Sage

Hi,



From which context are you accessing work note/comment? You can try this out from a notification mail script or business rule



  var worknote = current.work_notes.getJournalEntry(1);


  var worknoteContent = worknote.split("(Work notes)\n");


  var lastWorknote = worknoteContent[1];



Thanks


Abhinay Erra
Giga Sage

you can use getJournalEntry(1) will get only the latest entry


My requirement is little bit different ..   if anyone update either work note or additional comment   .... i have to take that as a comment on notifications....



For example if additional comment updated in last .. then it only slow last additional comment .. if worknote updated then worknote .. if noone updated then not showing anyone


Yes your notificarion conditions should be work notes changes or additional


comments changes. Then in email script use this


if(current.comments.changes())


template.print(current.comments.getJournalEntry(1));


else


template.print(current.work_notes.getJournalEntry(1));


On Mon, Feb 20, 2017 at 13:17 ankit_gupta <community-no-reply@servicenow.com>