Skip to content

Instantly share code, notes, and snippets.

Tim Woodruff thisnameissoclever

View GitHub Profile
thisnameissoclever / DynamicRefQuals.js
Last active Mar 7, 2019
DynamicRefQuals (Client-callable Script Include)
View DynamicRefQuals.js
var DynamicRefQuals= Class.create();
DynamicRefQuals.prototype = Object.extendsObject(AbstractAjaxProcessor, {
To quickly and easily create a dynamic reference qualifier script, simply add a custom method to this Script Include.
Here are the guidelines for modifying this Script Include:
1. In the "@author" JSDoc tag of the method your implement, please put your user ID (For example: "twoodruff").
2. See how the getGroupMembersByID and getGroupMembersByName methods are documented, and try to document your method in the same fashion.
3. Unless you've got permission from the author, please do not modify anyone else's methods.
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;
thisnameissoclever / JournalRedactor.js
Created Sep 8, 2018
Redact or delete a given journal entry in ServiceNow. Usage documentation:
View JournalRedactor.js
Script Include
Name: JournalRedactor
Client Callable: false
Accessible from: All scopes
Usage documentation:
var JournalRedactor = Class.create();
JournalRedactor.prototype = {
thisnameissoclever / Documentation & Article
Last active Mar 20, 2018
ServiceNow "Try in Portal" button
View Documentation & Article
thisnameissoclever / getMethodsAndProperties.js
Last active Jul 5, 2018
ServiceNow: Get Methods and Properties of an object
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.
thisnameissoclever / Deploy sub-prod config (background script).js
Last active Jul 5, 2018
ServiceNow - Deploy sub-prod configuration automatically
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();
thisnameissoclever / Client Script-Open GlideOverlay Window to Submit or Update Another Record.js
Created May 13, 2017
ServiceNow Client Script GlideOverlay: Open GlideOverlay Window to Submit or Update Another Record.js
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,
thisnameissoclever / ServiceNow Client Script-Get URI Param.js
Created May 13, 2017
This ServiceNow Client Script returns an object consisting of a property for each URI parameter, and its' value.
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] :;
thisnameissoclever / add object to object.js
Last active May 13, 2017
Add one object/array to another, avoiding "pass-by-reference" pitfalls in JavaScript.
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
You can’t perform that action at this time.