Help With Debugging ClientSide Scripts

Client side scripts are used extensively in ServiceNow. Whether from client script, UI scripts, UI policies, or back-end JS file includes (and a few other places but you get the point!).

It’s all fine until a script falls over and you get a javascript error. Checking the error in the javascript debugging console in whichever browser you choose will show you where it fell over but it’s not always clear exactly where this script lies and therefore where to fix it.

The issue (which is usually a very good thing by the way), is ServiceNow automatically puts all these client scripts that are needed to be loaded into big js_includes files. This basically gets all the scripts that need to be loaded, throws them into one big file and delivers it all at once, saving multiple round trips back and forward fetching each file.

So when a script fails, a lot of the times it’ll be in the js_includes file which doesn’t really help with debugging at all (well it does slightly help).
Continue reading

Workaround For GlideRecord SetWorkflow(false) Issue

As part of the GlideRecord API comes the function setWorkflow(false) .

If you’ve never used this before, essentially this function switches off the running of any subsequent business rules or workflows. This is really useful in a number of scenarios, for example when you need to update a lot of records in bulk and do not want emails to be automatically sent out for each one.

I’ve been recently working on archiving and using the OOB implementation was just too slow for us (OOB was taking approximately 5 minutes to archive one incident and 5 tasks, my custom one now archive 150 incidents, 500 tasks, all audit records, journal records, attachments etc, in less than a minute).

But while doing this, I needed to delete records from one place in ServiceNow and put them somewhere else. I didn’t want it audited that I deleted these records nor did I want business rules being triggered on the back of the deletions. So away I went setting setWorkflow(false) when deleting everything but this is where I stumbled across an issue… the business rules still ran, as did auditing!!

So I decided to dig a bit further, and I discovered that setWorkflow(false) doesn’t ALWAYS switch off business rules. Let me explain….
Continue reading

[Updated x2] Enabling Instant Chat Notifications (Chat Queues, Groups And Private)

Update 2 – ServiceNow demoed a new version of this chat functionality coming in Geneva version. Looking forward to this!

Update from ServiceNow – This is NOT recommended and is hidden as it is not scalable in large environments. Shame as this functionality looks awesome! It has my vote for a permanent feature in future 🙂

The chat plugin in ServiceNow is very good and extremely useful if used correctly.
It allows for instant messages to be sent through to colleagues or customers for quicker resolution.

The biggest drawback however that I’ve heard is that it’s not immediately obvious that someone has messaged you unless you’re in the chat window itself.

We looked at a number of options such as polling the server every minute to look for new chat messages to post alerts and creating new formatters but after some digging, we found a very very easy answer. And what’s better? It’s out of the box provided by ServiceNow! Hit after the break for a video of what it looks like and more importantly, how to enable it.

Continue reading