Basic understanding of getJournalEntry(-1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2020 11:33 AM
Hello Guys,
can anyone explain me in simple terms why do we use getJournalEntry(-1).
Thanks,
Teju
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2020 11:39 AM
This should help:
https://developer.servicenow.com/app.do#!/api_doc?v=newyork&id=SGE-getJournalEntry_N
getJournalEntry(1) Gives you the most recent entry
getJournalEntry(-1) Gives you all entries
We use it to grab last work note or approval rejection comments from time to time.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2020 11:40 AM
This returns all journal entries. This would be useful if you needed to print, email or send out all the comments/work notes/entries of a journal field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2020 11:50 AM
To expand on Steven and Elijah's answer it is important to understand that the comments and worknotes fields on tasks are actually of type journal input which behind the scenes causes the values populated into these types of fields to be stored into a separate table called Journal Entry (sys_journal_field). The value along with the user and timestamp are stored in that table. So in order to get the values of these types of fields the getJournalEntry() API was created and as Steven provides you can pass in a parameter to provide the number of historical journal entries to bring back.
Please mark this post or any as helpful or the correct answer to your question if applicable so others viewing may benefit.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2020 12:01 PM
I don't think you can put in just any number though, right?
Like...I was helping someone else and they just wanted to get the last 3, but they couldn't simply just do:
getJournalEntry(3), right?
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!