Testing xMatters JavaScript using Chrome's JavaScript Console

Posted by Travis DePuy  I  August 9, 12

If you are struggling to code and test JavaScript, especially when working within the xMatters application, then we have a great tip for you!

In HP Service Manager, there is an execute button on the ScriptLibrary records that executes the JavaScript you just entered. I didn’t find something like this in ServiceNow, as apparently you just use a UI Action. However, in xMatters, to test JavaScript, you have to restart a service so your code gets compiled, then run a command in the terminal, and then view the logs or the event report! Too many steps for me when trying to work quickly.

So, after some digging, I discovered the Chrome JavaScript Console. It allows you to code, test, debug and play with JavaScript.

Here is how you can access the JavaScript Console from within your Chrome browser:

Chrome JavaScript Console

The Chrome JavaScript Console allows you to execute JavaScript statements and immediately see the related output. Note: I used SHIFT + <enter> to get a new line rather than running the statement with just <enter>

Chrome JavaScript Console

It even provides "type ahead" functionality:

Chrome JavaScript Console - Type Ahead

I was playing with JSON objects and the console even breaks them out in a hierarchical fashion!

Chrome JavaScript Console - JSON Objects

And, clicking the arrows expand the JSON objects:

Chrome JavaScript Console - Expanding JSON Objects

As you can see, the Chrome JavaScript Console is very handy for any JavaScript developer... and if you are working with JavaScript in xMatters and are frustrated with all the necessary steps to perform simple JS testing, I consider it a must. Plus, it is free with your Chrome browser!

Anyone out there have any additional JavaScript coding and testing tips to share? Post them below, as I would love to swap ideas :-)


Tags:  xMatters, HP Service Manager, ServiceNow