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

Making Better Catalog UI Macros

Many of us would have played around with UI Macros before. They’re a very useful part of the system and they allow for all manners of customisations to the tool. This post is focussed on UI Macros on catalog items as this is where I generally use them the most, to make form submission easier.

One thing that you probably would have noticed is that you can’t use standard g_form methods on the UI macro to hide it, make it mandatory etc. nor can you use UI Policies. You can create custom client scripts to find the elements and hide/show them etc but this can be a bit annoying so I dug a little deeper to understand why and how to get them working. Low and behold, I found a VERY easy way to get them working!

Continue reading