Basic understanding of getJournalEntry(-1)

Tejaswini9
Tera Expert

Hello Guys,

can anyone explain me in simple terms why do we use getJournalEntry(-1).

Thanks,

Teju

10 REPLIES 10

Steven Parker
Giga Sage

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

Elijah Aromola
Mega Sage

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.

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

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.

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!