Instantly share code, notes, and snippets.

View GetAPIDocs.js
class APIClass {
* An APIClass object
* @param name {string} The name of the API class
constructor(name, classDesc = '') {
this._className = name;
this._classDescription = classDesc;
View JournalRedactor.js
Script Include
Name: JournalRedactor
Client Callable: false
Accessible from: All scopes
Usage documentation:
var JournalRedactor = Class.create();
JournalRedactor.prototype = {
View Documentation & Article
View getMethodsAndProperties.js
var methodsAndProperties = [];
var testObj = new GlideFilter('a=b', 'rule'); //TODO: replace this with whatever object you want to test
getMethodsAndProperties(methodsAndProperties, testObj);
gs.print('\n' + methodsAndProperties.join('\n'));
* Populates an extant array in-place, of methods and properties of a given object.
* @param methodsAndProperties {array} - the array to populate/modify in-place.
View Deploy sub-prod config (background script).js
function deployDevConfig() {
function _deactivateAllNonAdmins() {
var gr = new GlideRecord('sys_user');
View ClientTimeZoneUtils: Client-callable Script Include.js
var ClientTimeZoneUtils = Class.create();
ClientTimeZoneUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCurrentTimeInTimeZone: function() {
var tz = this.getParameter('sysparm_tz');
var tzu = new TimeZoneUtils();
var gdt = tzu.setTimeZone(tz);
return gdt.getDisplayValue();
View Client Script-Open GlideOverlay Window to Submit or Update Another Record.js
// opens a new u_error_reporting record from an sc_task record
function openOverlay(overlayID, overlayTitle, iframeURI, height, width) {
// Instantiate the GlideOverlay
// Note: GlideOverlay extends GlideBox, which contains the close() method
var overlayWindow = new GlideOverlay({
id: overlayID,
title: overlayTitle,
iframe: iframeURI,
allowOverflowX: true,
closeOnEscape: true,
View ServiceNow Client Script-Get URI Param.js
* Get the values of each URI param as properties of an object (name-value pairs).
* @param url
* @returns {{}}
* @example - In the URL, you could use getAllUrlParams().urip to get "pickles".
function getAllUrlParams(url) {
// get query string from url (optional) or window
var queryString = url ? url.split('?')[1] :;
View add object to object.js
* Adds one object to another, nesting the child object into the parent.
* this is to get around javascript's immutable handling of objects.
* @param name {String} - The name of the property of the parent object, in which to nest the child object. <br />For example, if the name parameter is set to "pickles" then "parent.pickles" will return the child object.
* @param child {Object} - The object that should be nested within the parent object.
* @param [parent={}] {Object} - The parent object in which to nest the child object. If the parent object is not specified, then the child object is simple nested into an otherwise empty object, which is then returned.
* @returns {Object} - A new object consisting of the parent (or an otherwise empty object) with the child object nested within it.
* @example
* //sets myNewObject to a copy of originalObject, which now also contains the original (yet un-linked) version of itself as a child, under the property name "original"
* var myNewObject = addObjToObj("orig