inmorphis-consu
Kilo Explorer

developer-utility.png

No doubt that ServiceNow is good tool, but sometimes a good thing is missing something very much important. Like this, many developers are missing a very basic functionality that they use a lot while developing stuffs i.e old functionality for saving stuffs "CTRL+S" or "MetaKey+S". Let us present you one Utility :SaveNow.

Developer Utility — SaveNow

At inMorphis, we have developed a utility SaveNow, which we use to save scripts. This is a small utility that saves a lot of time. Previously, developer used to save via "RIGHT CLICK" but now we use this utility.

Basic idea is to create a global UI Script that will capture the key events and trigger UI Action to save scripts.

Create a new UI Script.

UI Script: SaveNow

Global: true
Active: true
Script:

  1. /*
  2. Add Event Listener on key down event for CTRL+S
  3. */
  4. document.addEventListener("keydown", function(event) {
  5.    
  6. //keycode 83 is for s
  7. //identify main key ==> metakey || ctrlkey
  8.   if ((window.navigator.platform.toUpperCase().indexOf('MAC')>=0 ? event.metaKey : event.ctrlKey)   && event.keyCode == 83) {
  9.    
  10.     //Get the event value, "event.which" is for FF
  11.   event=event||window.event||event.which;
  12.    
  13.     //Prevent the dafault function called by CTRL+S
  14.   event.preventDefault();
  15.    
  16.     //Get full element of the form
  17.     var _form=g_form.getFormElement();
  18.    
  19.     //Get the sys_id value from the URL to check which UI Action needs to be called
  20.     var _sys=getParameterFromURL("sys_id").toString();
  21.    
  22.     //Based on value of sys_id, we will decide that which UI Action needs to be called, either for insert or Update
  23.     var _btnAction=_sys=="-1"?"sysverb_insert_and_stay":"sysverb_update_and_stay";
  24.    
  25.     //call the UI Action
  26.   gsftSubmit(null, _form, _btnAction);
  27.    
  28.   }
  29. }, false);

You can also copy this code form github repository or download the UpdateSet from github.

Let us know, IF you are facing any issue while using this UpdateSet.

To read more such interesting posts. Click here

----
visit www.inMorphis.com/blogs/ for more