Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

gaidem
ServiceNow Employee
ServiceNow Employee

First off, sorry to the community members. I've been super busy these days and haven't been able to respond to posts as much as I would like. Here's an example of what's been keeping me busy.

Yesterday (Sunday) I get notified that our production instance crashed. For about 7 hours the instance was extremely slow and had to be rebooted almost 10 times. So what happened?

We received a spam ticket with CC's that ended up adding several donotreply addresses on the watch list and created a loop. This alone wasn't new to me. However, each of the bounce backs from the addresses were HUGE in size. For example 1 was 357 pages in length and over 1.5 million characters.

The Incident record became so big that any query related to it would deplete all the system resources. I don't mean opening the record, I mean referencing tables like sys_email that had a reference to this record.

Because of this I have developed a preventative solution for the future. This solution will prevent updates to a ticket once the specified journal field character count exceeds a new property I have created:

Create a new field on the task table: u_journal_count
Create a new system property:
Name: task.journal.limit
Type: integer
Value: Specify the amount of characters you want to limit (-1 equals no limit)

Now create a before insert/update business rule on the task table:
Condition: current.work_notes.changes()
Script:



var limit = gs.getProperty('task.journal.limit');
if(limit!='-1'){
var journalCount = current.u_journal_count;
var wrkNotes = current.work_notes;
var wrkNotesSPLT = wrkNotes.split('');
if((wrkNotesSPLT.length + journalCount)> limit){
current.setAbortAction(true);
gs.addInfoMessage("The Client Communication field has exceeded its journal limit");
}
else{
current.u_journal_count += wrkNotesSPLT.length;
}
}


Regards,

3 Comments