Adding Worknotes From a Script (ServiceNow)

I recently had a need to add work notes to a bunch of old incidents (to let the users know that they had changed and why they had been changed). My first approach was just to add a record to the sys_journal_field table.

At first blush, that seemed to work, but then a co-worker pointed out that the work note was showing up in the history tab with the wrong user, and at the wrong time.

It appears that the automation responsible for populating work notes into the activities feed in the history tab didn’t like me just inserting a record into that table.

I ended up using this code, which seems to do the trick of getting the work note into the sys_journal_field table, and pushing it into the activities feed correctly as well.

incidents['work_notes'].setJournalEntry("The text you want to appear in your work note...);