JournalRedactor - Easily Redact or Delete Journal Entries in ServiceNow!

After being asked how to remove information from, or delete, a journal entry three times in as many days, I finally decided to get off my butt, and write this tool. Then I realized that it's difficult to code standing up, so I sat down back on my butt, and got to work. 

If you've ever tried to modify or delete a journal entry, you probably already know what an ordeal it can be, and you've likely sunk hours into the attempt, if not thrown your hands up in frustration altogether! There are at least four distinct tables involved in modifying/redacting or deleting a journal entry, each with a unique schema, some dependent on others, and some stand-alone: 

  1. Journal Entry [sys_journal_field]
  2. Audit [sys_audit]
  3. History Set [sys_history_set]
  4. History line [sys_history_line]

"Why the hell is this so complicated?" would not be an unreasonable question to ask, but each of these tables actually does serve a unique and valuable purpose. The difficult part (once you've identified all of the tables a journal entry's data might reside in), is identifying how they all work together. Then you have to actually locate the record in each table that corresponds to the specific journal entry you want to redact, and modify it in some way (which may be different depending on what you're trying to do, and what table you're interacting with. 

Or - you could simply grab the tool I've just written, and use that instead. 

The tool is simply a Script Include, which you can see the complete contents of  (as of v1.1) in this Gist. You can find the download link and complete API documentation by going to the Tools menu at the top of this page, and clicking JournalRedactor, or by clicking here.

Once JournalRedactor is installed in your instance, you can redact or delete a journal entry in a few ways - most commonly, the following:

var targetRecordID = '1c741bd70b2322007518478d83673af3'; //sys_id of the record on which the journal entry resides
var oldJournalText = 'customer social is 123-45-6789'; //The EXACT, COMPLETE text of the journal entry to be redacted.

var redactor = new JournalRedactor();
redactor.findJournalID(targetRecordID, oldJournalText);
redactor.redact(false, '[REDACTED]');

See the complete API documentation for more info and usage examples, or post a comment below if you have any questions!

Advanced users who already know a fair bit about the REST API Explorer: Skip to 8:48 for the exact info you're looking for!
This video walks you through how to access catalog or record producer variables from ServiceNow via the REST table API, with minimal fuss.