Notes from working for Service Now

I've been working for Service Now since Labor day of 2012. I've had to do things to the poor platform it was never intended to allow.
So, here's some of them. Maybe you'll find 'em useful.

Killing long running processes

Go to https://<my_instance_url>/cancel_my_transactions.do will cancel any script and DB queries associated with your current session.

Removing a Script Include from the current context

My usage:

//re-include qunit to allow for multiple runs
try{  
    sys_include_map.remove('QUnitLoader');
    sys_include_map.remove('QUnit-v1.23');
    GlideController.removeGlobal("QUnit");
    GlideController.removeGlobal("exports");
}catch(e){
    CidQUnit2.log("could not remove QUnitLoader")
}
gs.include('QUnitLoader');  

QUnitLoader creates a global exports object, to allow QUnit to include itself on, then copies exports.QUnit to the global namespace. This code removes the names from the record the system keeps of already included scripts (keeps from re-including scripts that have already been used).
Then it removes the global references the scripts create.
If you are using standard SNC Script includes, then it becomes a bit easier:

sys_include_map.remove('<name_of_script_include>');  
GlideController.removeGlobal('<name_of_script_include>');  
Logging tricks
  • gs.print() will log only to your session,(activate System Diagnostics -> Debug Log) gs.log() will log to your session, as well as system logs.
    Problem with gs.print is that it always prefixes the output with *** Script:. If you don't want this, use GlideLog.print()

  • GlideSysLog.info('QUnit', message); //same as gs.log()

  • GlideLog.info('QUnit: ' + message); //same as gs.print(), but without that *** Script: prefix