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).

The ideal thing here would be to bring back each file back individually so when we find the issue, we can identify exactly the file or script it’s failing in!

To do this, there’s a property called glide.ui.js_includes. Set this property value to false and then continue debugging. Just like magic all the files are delivered from the server as individual files.

DISCLAIMER: REMEMBER TO SWITCH THIS BACK AND MAKE SURE IT’S NOT CARRIED OVER INTO PRODUCTION!!
End of disclaimer 🙂

1 Comment

  1. Pingback: Ordering Of OnLoad Scripts | Service Now Gems

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s