setJournalEntry not working correctly, in many ways
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2018 01:59 PM
setJournalEntry is behaving inconsistently for us when running a script that mass closes and appends a journal entry to a chosen list of tasks; at times it will work correctly, at others we are seeing three incorrect behaviors for setJournalEntry:
- No entry appears at all in Activities, but does appear in sys_journal_field
- The string value provided for the Username is ignored and username of user that ran the script is entered instead.
- Entry is shoehorned somewhere in the middle of the Activity, with a user and timestamp associated with Update 0 in the History List, instead of the correct information in the sys_audit table
We are setting setUseEngines to false to prevent some of our automated behaviors from occurring instead of setWorkflow, as setJournalEntry doesn't even work when we use setWorkflow.
EDIT/UPDATE
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2018 02:05 PM
Instead of using setJournalEntry, you can just do this:
RECORDNAME.comments = "your comments" and this will create a journal entry. Please note that setValue() does not work with journal fields as mentioned here:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2018 02:13 PM
I'll remember that for the future, but the damage has been done so far.
I suppose we'll need to undo what the script has done and try a script RECORDNAME.comments = "your comments" instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2018 02:17 PM
Sorry to hear damage has been done. I would highly recommend running mass scripts like this in a test environment first.
I know this doesn't help you now, but there is a Rollback feature coming in London!
https://community.servicenow.com/community?id=community_blog&sys_id=27804903db63530054250b55ca961938
Please mark any post as helpful or the correct answer to your question so others may benefit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2018 02:22 PM
Oh yes, we did, and it was all perfect there, I seem to have neglected to mention that though. I'll edit appropriately.
After some additional investigation the sys_audit table shows the correct information for all of the edited tasks.
However the Activity stream and History List are showing completely erroneous information.
Original script was run in a subprod and all tested tasks looked perfect there. Only after running this in production instance did things go completely sideways.