Using the last input data from a journaled field

General Add comments
by:

brave Sometimes you get a request that sounds simple and you bravely tell the requester that arranging this won’t take more than just a few seconds.
And sometimes, shortly after your brave remark to the requester, you realize you’d better investigate just a little further before making brave statements ๐Ÿ˜‰

Now if you think I’m talking about myself here, yep – you are absolutely right…..

 

And I’m a not a die-hard techie that spends his days implementing, so my ServiceNow knowledge is limited to functional knowledge with some experience in configuring.
Yes, I’m making excuses here, just to feel good about myself ๐Ÿ™‚

Let’s get back to the topic, I’m losing myself here..
When our Marketing lady recently asked me to add a column to her list view where she could see the last update to the Comments field, I told here this was no problem, she could just use the Personalize option in the list view and add the Comments column.
At the time of asking I did not think about the Comments field being a journaled field – but I found out pretty quickly once she told me she added the column but no data was in it.

You ServiceNow guru’s of course already understand what happened – so did I.

The challenge was more how to solve this and get only the last update entered into the Comments-field into her List view.

Was with many things in ServiceNow the answer was simple – but had to come from one of our die-hard techie consultants, so all credits for this go to him! (thank you Menno)

Solution

By adding a new field of type String where Calculated = TRUE and the calculation-field contains “current.comments.getJournalEntry(1);” the solution was there!
Pretty simple, right? And it works like a charm – can be added to the personalized list too.

Now this is just a sample for the Comments field, but will of course work for any journaled field; just replace the fieldname in the calculation-field with your (journal)field name – and off you go.

Our marketing lady is happy – and so am I with this simple yet powerful solution.

And I cannot mention this enough: use the Wiki to look for answers.
I didn’t of course, but if I did I would have found the solution there too: check HERE.

Any questions? You can contact me at .img[at].img.

3 Responses to “Using the last input data from a journaled field”

  1. Antony Mirza Says:

    Hi Fred, Thanks for sharing but how to display only contents and avoid displaying the following in this column in list view:
    1. Date and Time
    2. Logged in User name

    e.g. 2014-12-23 08:20:29 System Administrator ( Additional comments) which is very annoying.

    Hope to hear from you ๐Ÿ™‚

    Brgds, AM

  2. Fred K Says:

    Hello Antony, thank you for your comment. And yes, you can achieve what you are looking for, it will require some scripting – where the result will be what you’ve asked.
    You can call a script in the calculated field and in the script you’ll need to create something like: find the 4th space from the getJournalEntry and remove everything before this.

    With some scripting experience you will come a long way ๐Ÿ™‚

    Thanks.

    BR, Fred.

  3. Mo Says:

    Hi Fred,
    I am having same issue. can you please show example script to remove data time and logged user name from the last comments.
    e.g. 2014-12-23 08:20:29 System Administrator ( Additional comments) which is very annoying.

Leave a Reply