Counting Journal Entries
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2013 07:24 AM
Currently I am working on the Incident table and am trying to get the number of updates an Incident has, also known as how many journal entries each incident has. I realize from this WIKI that I can get the contents of a journal field into an array which is very useful:
http://wiki.servicenow.com/index.php?title=Using_Journal_Fields#Getting_the_Contents_of_a_Journal_Field_into_an_Array
What I am trying to do is NOT get a certain element of a journal entry but a journal entry set as a single entity in itself. With the example code you can grab the number of additional comments entered, the number of state changes, the number of closed notes, etc. But what I'm trying to get are the number of updates that are separated by the timestamp entry. Example is a screenshot of what I'm trying to explain.
Is there any way to count these "entry sets" ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2013 07:53 AM
You could put the journal entries into an array and count the array entries.
Perhaps an easier approach: There is an OOB field called 'Updates' on the INC table. It counts every 'update' to the table. Will this perhaps fit your needs?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2013 08:07 AM
And that's why I ask - Thank you Terri!
The OOB option is very direct and is exactly what I was looking for and I see that this element is available on most popular tables used (if not all form tables used).
gs.log('Current Update Count: ' + current.sys_mod_count);
Outputs:
Current Update Count: [Integer >= 1]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2013 08:15 AM
You are correct the field is actually on the TASK table so available on any table that extends TASK.
Please mark this request as Answered if this solution worked for you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2017 07:39 AM
It's an old post, still i want to answer , the comments_work_notes is giving the correct result, I think there is a documentation update pending..
var notes = current.comments_and_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 j = 0; j < na.length; j++);