├── .gitignore ├── ES6 ├── sn_hw.js ├── sn_uc.js ├── sn_cmdbgroup.js ├── sn_cmdb.js ├── sn_connect.js ├── sn_cc.js ├── sn_clotho.js ├── sn_auth.js ├── GlideFormScratchpad.js ├── sn_ws.js ├── GlideScriptableInputStream.js ├── sn_sc.js ├── Client.js ├── GlideGuidV3.js ├── spAriaUtil.js ├── StopWatch.js ├── GlideNotificationV3.js ├── CustomEvent.js ├── TemplatePrinter.js ├── RESTAPIRequest.js ├── Queue.js ├── ScriptLoader.js ├── GlidePluginManager.js ├── JSON.js ├── GlideLocale.js ├── GlideDocumentV3.js ├── TransformResult.js ├── GlideOAuthToken.js ├── GlideUICompatibility.js ├── GlideOAuthClientResponse.js ├── GlideFilter.js ├── GlideTextReader.js ├── GlideURLV3.js ├── GlideSysListControl.js ├── GlideServletResponse.js ├── GlideSecureRandomUtil.js ├── CatalogSearch.js ├── RESTAPIResponseStream.js ├── VariablePoolQuestionSetJS.js ├── i18NV3.js ├── RESTAPIRequestBody.js ├── PAScorecard.js ├── GlideNavigationV3.js ├── ConnectionInfoProvider.js ├── ConnectionInfo.js ├── GlideScriptedProcessor.js ├── CatalogItemVariable.js ├── CatalogItemVariableSet.js ├── StandardCredentialsProvider.js ├── GlideURI.js ├── CatalogItemVariableSetM2M.js ├── DataBuilder.js ├── XMLNodeIterator.js ├── Data.js ├── GlideServletRequest.js ├── Transformer.js ├── RenderProperties.js ├── GlideModalFormV3.js ├── GlideOAuthClient.js ├── CertificateEncryption.js ├── GlideQueryCondition.js ├── GlideExcelParser.js ├── Conversation.js ├── GlideMenu.js ├── GlideEmailOutbound.js ├── GlideDialogWindow.js ├── OrderGuide.js ├── Mobile.js ├── GlideTableHierarchy.js ├── PASnapshot.js ├── GlideSysAttachment.js ├── CatCategory.js ├── Workflow.js ├── SOAPResponseV2.js ├── GlideAjaxV3.js ├── RESTAPIResponse.js ├── GlideDuration.js ├── GlideOAuthClientRequest.js ├── GlideScopedEvaluator.js ├── GlideAjax.js ├── GlideSession.js ├── GlideModalV3.js └── GlideUser.js ├── ES5 ├── NameMapEntry.js ├── GlideEventHandler.js ├── MultipleUpdate.js ├── StackManagement.js ├── scrollable.js ├── String Class Extensions.js ├── email_activity.js ├── GlidePane.js ├── ac_derived_field_support.js ├── DerivedFields.js ├── functions_reference.js ├── StopWatch.js ├── AjaxOtherCompleter.js ├── CustomEventManager.js ├── GlideClientCache.js ├── CurrencyFormat.js ├── TemplateRecord.js ├── AjaxReferenceChoice.js ├── User.js ├── Class.js ├── AutoComplete.js ├── TableExtension.js ├── Select.js ├── AjaxTableCompleter.js ├── GlideDuration.js ├── GlidePaneForm.js ├── GlideUser.js ├── PartialPage.js ├── CookieJar.js ├── rico_effect.js └── GlideDialogWindow.js └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | \.idea -------------------------------------------------------------------------------- /ES6/sn_hw.js: -------------------------------------------------------------------------------- 1 | const sn_hw = { 2 | "HistoryWalker": HistoryWalker 3 | }; -------------------------------------------------------------------------------- /ES6/sn_uc.js: -------------------------------------------------------------------------------- 1 | const sn_uc = { 2 | "UserCriteria": UserCriteria 3 | }; -------------------------------------------------------------------------------- /ES6/sn_cmdbgroup.js: -------------------------------------------------------------------------------- 1 | const sn_cmdbgroup = { 2 | "CMDBGroupAPI": CMDBGroupAPI 3 | }; -------------------------------------------------------------------------------- /ES6/sn_cmdb.js: -------------------------------------------------------------------------------- 1 | const sn_cmdb = { 2 | "IdentificationEngine": IdentificationEngine 3 | }; -------------------------------------------------------------------------------- /ES6/sn_connect.js: -------------------------------------------------------------------------------- 1 | const sn_connect = { 2 | "Conversation": Conversation, 3 | "Queue": Queue 4 | }; -------------------------------------------------------------------------------- /ES6/sn_cc.js: -------------------------------------------------------------------------------- 1 | const sn_cc = { 2 | "ConnectionInfo": ConnectionInfo, 3 | "ConnectionInfoProvider": ConnectionInfoProvider, 4 | "StandardCredentialsProvider": StandardCredentialsProvider 5 | }; -------------------------------------------------------------------------------- /ES5/NameMapEntry.js: -------------------------------------------------------------------------------- 1 | //include classes/util/NameMapEntry.js 2 | var NameMapEntry = Class.create({ 3 | initialize: function (prettyName, realName) { 4 | this.prettyName = prettyName; 5 | this.realName = realName; 6 | } 7 | }); -------------------------------------------------------------------------------- /ES6/sn_clotho.js: -------------------------------------------------------------------------------- 1 | const sn_clotho = { 2 | "Client": Client, 3 | "Data": Data, 4 | "DataBuilder": DataBuilder, 5 | "TransformPart": TransformPart, 6 | "TransformResult": TransformResult, 7 | "Transformer": Transformer 8 | }; -------------------------------------------------------------------------------- /ES6/sn_auth.js: -------------------------------------------------------------------------------- 1 | const sn_auth = { 2 | "GlideOAuthClient": GlideOAuthClient, 3 | "GlideOAuthClientRequest": GlideOAuthClientRequest, 4 | "GlideOAuthClientResponse": GlideOAuthClientResponse, 5 | "GlideOAuthToken": GlideOAuthToken 6 | }; -------------------------------------------------------------------------------- /ES6/GlideFormScratchpad.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The scoped GlideFormScratchpad class implements the g_scratchpad 3 | * object for scoped applications. 4 | * @class GlideFormScratchpad 5 | * @typedef {Object} GlideFormScratchpad 6 | */ 7 | class GlideFormScratchpad {} -------------------------------------------------------------------------------- /ES5/GlideEventHandler.js: -------------------------------------------------------------------------------- 1 | //include classes/GlideEventHandler.js 2 | var GlideEventHandler = Class.create({ 3 | initialize: function (handlerName, handler, fieldName) { 4 | this.handlerName = handlerName; 5 | this.handler = handler; 6 | this.fieldName = fieldName; 7 | } 8 | }); -------------------------------------------------------------------------------- /ES5/MultipleUpdate.js: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | 6 | 7 | 8 | //var Packages.com.glide.db.MultipleUpdate = Class.create(); 9 | 10 | //Packages.com.glide.db.MultipleUpdate.prototype = { 11 | 12 | //}; 13 | -------------------------------------------------------------------------------- /ES6/sn_ws.js: -------------------------------------------------------------------------------- 1 | const sn_ws = { 2 | "RESTAPIRequest": RESTAPIRequest, 3 | "RESTAPIRequestBody": RESTAPIRequestBody, 4 | "RESTAPIResponse": RESTAPIResponse, 5 | "RESTAPIResponseStream": RESTAPIResponseStream, 6 | "RESTMessageV2": RESTMessageV2, 7 | "RESTResponseV2": RESTResponseV2, 8 | "SOAPMessageV2": SOAPMessageV2, 9 | "SOAPResponseV2": SOAPResponseV2 10 | }; -------------------------------------------------------------------------------- /ES6/GlideScriptableInputStream.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A GlideScriptableInputStream object cannot be instantiated directly, but is used as an 3 | * opaque object which is used to connect an input stream from 4 | * GlideSysAttachment.getContentStream() with other streaming APIs, such as 5 | * GlideTextReader, GlideDigest, and XMLDocument2. 6 | * @class GlideScriptableInputStream 7 | * @typedef {Object} GlideScriptableInputStream 8 | */ 9 | class GlideScriptableInputStream {} -------------------------------------------------------------------------------- /ES6/sn_sc.js: -------------------------------------------------------------------------------- 1 | const sn_sc = { 2 | "CartJS": CartJS, 3 | "CatCategory": CatCategory, 4 | "CatItem": CatItem, 5 | "CatalogClientScript": CatalogClientScript, 6 | "CatalogItemVariable": CatalogItemVariable, 7 | "CatalogItemVariableSet": CatalogItemVariableSet, 8 | "CatalogItemVariableSetM2M": CatalogItemVariableSetM2M, 9 | "CatalogJS": CatalogJS, 10 | "CatalogSearch": CatalogSearch, 11 | "OrderGuide": OrderGuide, 12 | "VariablePoolQuestionSetJS": VariablePoolQuestionSetJS 13 | }; -------------------------------------------------------------------------------- /ES5/StackManagement.js: -------------------------------------------------------------------------------- 1 | //include classes/StackManagement.js 2 | /** 3 | * Keep track of the stack per tab/window 4 | * 5 | * - Stack name is stored in window.name of the top window 6 | */ 7 | var StackManagement = Class.create({ 8 | initialize: function() { 9 | }, 10 | setStackName: function() { 11 | var w = getTopWindow(); 12 | if (!w.name || !w.name.startsWith("snc:")) 13 | w.name = "snc:" + guid(); 14 | }, 15 | getStackName: function() { 16 | var w = getTopWindow(); 17 | return w.name; 18 | }, 19 | type: 'StackManagement' 20 | }); -------------------------------------------------------------------------------- /ES6/Client.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides methods to add data to the MetricBase database, to execute 3 | * transforms on the MetricBase 4 | * database, and to receive the results of the transforms. 5 | * @class Client 6 | * @typedef {Object} Client 7 | */ 8 | class Client { 9 | /** 10 | * Creates an instance of the client class to access the MetricBase database. 11 | */ 12 | constructor() {} 13 | /** 14 | * Save metric data to the MetricBase database. 15 | * @param {DataBuilder} metricData A DataBuilder object containing metric data. 16 | * @returns Method does not return a value 17 | */ 18 | put(metricData) {} 19 | } -------------------------------------------------------------------------------- /ES6/GlideGuidV3.js: -------------------------------------------------------------------------------- 1 | /** 2 | * You can create a globally unique identifier. 3 | * @class GlideGuidV3 4 | * @typedef {Object} GlideGuidV3 5 | */ 6 | class GlideGuidV3 { 7 | constructor() {} 8 | /** 9 | * Creates a globally unique identifier 32 characters long, or as specified with the 10 | * optional length argument. 11 | * @param {Number} stringLength The desired string length, must be between 1 and 32 inclusive. This parameter 12 | * is optional. If not specified, the returned string will be 32 characters 13 | * long. 14 | * @returns The globally unique identifier. 15 | */ 16 | generate(stringLength) {} 17 | } -------------------------------------------------------------------------------- /ES6/spAriaUtil.js: -------------------------------------------------------------------------------- 1 | /** 2 | * You can show messages on a screen reader. The spAriaUtil service is an angular service 3 | * included as part of the Service Portal angular application. The spAriaUtil service is available 4 | * in the client script block of Service Portal widgets. 5 | * @class spAriaUtil 6 | * @typedef {Object} spAriaUtil 7 | */ 8 | class spAriaUtil { 9 | constructor() {} 10 | /** 11 | * Announce a message to a screen reader. 12 | * @param {String} message The message to be shown. 13 | * @returns Method does not return a value 14 | * @example function(spAriaUtil) { 15 | * // widget controller 16 | * spAriaUtil.sendLiveMessage('Hello world!'); 17 | * } 18 | */ 19 | sendLiveMessage(message) {} 20 | } -------------------------------------------------------------------------------- /ES5/scrollable.js: -------------------------------------------------------------------------------- 1 | //defer scrollable.js 2 | var HOME_SCROLL_SPEED = 1; 3 | var HOME_PAUSE_SPEED = 0; 4 | var HOME_RESUME_SPEED = 1; 5 | function scroller(divName) { 6 | var target = gel(divName); 7 | if (!target) 8 | return; 9 | var wrapper = gel(divName+"_wrap"); 10 | var wrapperHeight = wrapper.offsetHeight; 11 | var containerHeight = target.offsetHeight; 12 | var actualheight = wrapperHeight 13 | if (wrapperHeight < containerHeight) 14 | actualheight = containerHeight; 15 | var currentScroll = parseInt(target.style.top) - HOME_SCROLL_SPEED; 16 | var bottom = actualheight + parseInt(target.style.top); 17 | if (bottom < 20) 18 | currentScroll = wrapperHeight; 19 | target.style.top=currentScroll + "px"; 20 | } -------------------------------------------------------------------------------- /ES6/StopWatch.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use a StopWatch object to measure the duration of operations. 3 | * @class StopWatch 4 | * @typedef {Object} StopWatch 5 | */ 6 | class StopWatch { 7 | /** 8 | * Creates an instance of the StopWatch class. 9 | */ 10 | constructor() {} 11 | /** 12 | * Returns the number of milliseconds since the timer started. 13 | * @returns The number of milliseconds since the timer started. 14 | */ 15 | getTime() {} 16 | /** 17 | * Resets the timer to the current time. 18 | * @returns Method does not return a value 19 | */ 20 | restart() {} 21 | /** 22 | * The elapsed time as HH:MM:SS.SSS. 23 | * @returns The elapsed time formatted as HH:MM:SS.SSS. 24 | */ 25 | toString() {} 26 | } -------------------------------------------------------------------------------- /ES6/GlideNotificationV3.js: -------------------------------------------------------------------------------- 1 | /** 2 | * You can show messages over the page content. 3 | * @class GlideNotificationV3 4 | * @typedef {Object} GlideNotificationV3 5 | */ 6 | class GlideNotificationV3 { 7 | constructor() {} 8 | /** 9 | * Displays the specified string over the page content as the specified type of 10 | * message. 11 | * @param {String} type The type of message - error, warning, or info. 12 | * @returns Method does not return a value 13 | * @example // Displays an info message at the top of the screen 14 | * nowapi.g_notification.show("info", "The record has been updated"); 15 | * // Displays an error message at the top of the screen 16 | * nowapi.g_notification.show("error", "You need to provide notes!"); 17 | */ 18 | show(type) {} 19 | } -------------------------------------------------------------------------------- /ES6/CustomEvent.js: -------------------------------------------------------------------------------- 1 | /** 2 | * You can use CustomEvent API to show qualified embedded help in the right 3 | * sidebar. 4 | * @class CustomEvent 5 | * @typedef {Object} CustomEvent 6 | */ 7 | class CustomEvent { 8 | constructor() {} 9 | /** 10 | * Show the embedded-help content specified by the qualifier parameter in the right 11 | * sidebar. 12 | * @param {String} event The event to send. Must be the string 13 | * "embedded_help:load_embedded_help" 14 | * @param {String} qualifier The qualifier name created in the Embedded Help application. 15 | * @returns Method does not return a value 16 | * @example var qualifier = 'your-EH-qualifier'; 17 | * CustomEvent.fireAll("embedded_help:load_embedded_help", qualifier); 18 | */ 19 | fireAll(event, qualifier) {} 20 | } -------------------------------------------------------------------------------- /ES6/TemplatePrinter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Scoped TemplatePrinter handles printing from a mail script to the email message. 3 | * @class TemplatePrinter 4 | * @typedef {Object} TemplatePrinter 5 | */ 6 | class TemplatePrinter { 7 | constructor() {} 8 | /** 9 | * Prints the string to the email body. 10 | * @param {String} string The string to print 11 | * @returns Method does not return a value 12 | * @example template.print("Incident number - " + current.number + "\n"); 13 | */ 14 | print(string) {} 15 | /** 16 | * Adds non-breaking spaces to the email body. 17 | * @param {Number} spaces The number of non-breaking spaces to output to the email body. 18 | * @returns Method does not return a value 19 | * @example template.space(4); 20 | */ 21 | space(spaces) {} 22 | } -------------------------------------------------------------------------------- /ES6/RESTAPIRequest.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A RESTAPIRequest object allows you to access scripted REST API request details in 3 | * scripts. 4 | * @class RESTAPIRequest 5 | * @typedef {Object} RESTAPIRequest 6 | */ 7 | class RESTAPIRequest { 8 | constructor() {} 9 | /** 10 | * Returns the value of a specific header from the web service request. 11 | * @param {String} header The name of the header, such as accept or 12 | * content-type. 13 | * @returns {string} The value of the specified header. 14 | * @example var acceptHeader = request.getHeader('accept'); 15 | */ 16 | getHeader(header) {} 17 | /** 18 | * Get the content types specified in the request Accept header. 19 | * @returns An array of string values where each string is a content type, such as 20 | * application/json. 21 | */ 22 | getSupportedResponseContentTypes() {} 23 | } -------------------------------------------------------------------------------- /ES5/String Class Extensions.js: -------------------------------------------------------------------------------- 1 | String.prototype.startsWith =function(prefix){ 2 | return (this.substr(0,prefix.length)==prefix); 3 | } 4 | 5 | String.prototype.endsWith = function(s) { 6 | if (!s) 7 | return false; 8 | 9 | if (this.length < s.length) 10 | return false; 11 | 12 | return (this.substr(this.length - s.length, s.length) == s); 13 | } 14 | 15 | String.prototype.trimLeft =function(){ 16 | return this.replace(/^\s*/,""); 17 | } 18 | 19 | String.prototype.trimRight =function(){ 20 | return this.replace(/\s*$/,""); 21 | } 22 | 23 | String.prototype.trim =function(){ 24 | return this.trimRight().trimLeft(); 25 | } 26 | 27 | String.prototype.replaceAll = function(from, to) { 28 | var str = this; 29 | var idx = str.indexOf( from ); 30 | 31 | while ( idx > -1 ) { 32 | str = str.replace( from, to ); 33 | idx = str.indexOf( from ); 34 | } 35 | 36 | return str; 37 | } -------------------------------------------------------------------------------- /ES6/Queue.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The Queue API allows you to retrieve or join a Connect Support chat queue. 3 | * @class Queue 4 | * @typedef {Object} Queue 5 | */ 6 | class Queue { 7 | constructor() {} 8 | /** 9 | * Get an existing chat queue by sys_ID. 10 | * @param {String} SysID The sysID of a queue from the chat_queue table. 11 | * @returns Returns a conversation queue object. 12 | * @example var queue = sn_connect.Queue.get("ab73be7dc09a4300964f336ee6b74361"); 13 | */ 14 | get(SysID) {} 15 | /** 16 | * Adds the current user to an existing Connect Support chat queue. Use a sysID 17 | * from the chat_queue table. 18 | * @param {String} Question Type a question to add to the queue. 19 | * @returns Method does not return a value 20 | * @example var queue = sn_connect.Queue.get("ab73be7dc09a4300964f336ee6b74361"); 21 | * queue.join("How do I access my email?"); 22 | */ 23 | join(Question) {} 24 | } -------------------------------------------------------------------------------- /ES6/ScriptLoader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides the ability to load scripts asynchronously. 3 | * @class ScriptLoader 4 | * @typedef {Object} ScriptLoader 5 | */ 6 | class ScriptLoader { 7 | constructor() {} 8 | /** 9 | * Loads scripts asynchronously. 10 | * @param {Array} scripts An array of scripts. 11 | * @param {Function} callback The function called when the scripts have been loaded. The callback function 12 | * has no arguments. 13 | * @returns Method does not return a value 14 | */ 15 | getScripts(scripts, callback) {} 16 | /** 17 | * Gets scripts asynchronously. 18 | * @param {String} filePath A path, including the file name, that contains one or more scripts. 19 | * @param {Function} callback The function to be called after the scripts have been loaded. The callback 20 | * function has no arguments. 21 | * @returns Method does not return a value 22 | */ 23 | getScripts(filePath, callback) {} 24 | } -------------------------------------------------------------------------------- /ES6/GlidePluginManager.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The scoped GlidePluginManager API provides a method for determining if a plugin has been 3 | * activated. 4 | * @class GlidePluginManager 5 | * @typedef {Object} GlidePluginManager 6 | */ 7 | class GlidePluginManager { 8 | constructor() {} 9 | /** 10 | * Determines if the specified plugin has been activated. 11 | * @param {String} pluginID The plugin ID 12 | * @returns True if the plugin has been activated. 13 | * @example var gr = new GlideRecord('sys_plugins'); 14 | * var queryString = "active=0^ORactive=1"; 15 | * gr.addEncodedQuery(queryString); 16 | * gr.query(); 17 | * pMgr = new GlidePluginManager(); 18 | * while (gr.next()) { 19 | * var name = gr.getValue('name'); 20 | * var pID = gr.getValue('source'); 21 | * isActive = pMgr.isActive(pID); 22 | * if (isActive) 23 | * gs.info('The plugin ' + name + " is active" ); 24 | * } 25 | */ 26 | isActive(pluginID) {} 27 | } -------------------------------------------------------------------------------- /ES6/JSON.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides scoped methods to create JSON objects from a string, and to turn JSON objects 3 | * into strings. 4 | * @class JSON 5 | * @typedef {Object} JSON 6 | */ 7 | /* 8 | class JSON { 9 | constructor() {} 10 | /!** 11 | * Creates an object or primitive type from a JSON formatted string. 12 | * @param {String} str A JSON formatted string. 13 | * @returns An object created from the specified string. 14 | * @example var str = '{"name":"George","lastname":"Washington"}'; 15 | * var obj = JSON.parse(str); 16 | * gs.info('The first name is' + obj.name); 17 | *!/ 18 | parse(str) {} 19 | /!** 20 | * Creates a string from a JSON object. 21 | * @param {Object} jsonObject The JSON object to be turned into a string. 22 | * @returns A JSON formatted string. 23 | * @example var obj = {"name":"George","lastname":"Washington"}; 24 | * var str = JSON.stringify(obj); 25 | * gs.info('The object' + str); 26 | * 27 | *!/ 28 | stringify(jsonObject) {} 29 | }*/ 30 | -------------------------------------------------------------------------------- /ES6/GlideLocale.js: -------------------------------------------------------------------------------- 1 | /** 2 | * GlideLocale provides information about display information for the local 3 | * instance. 4 | * @class GlideLocale 5 | * @typedef {Object} GlideLocale 6 | */ 7 | class GlideLocale { 8 | constructor() {} 9 | /** 10 | * Returns the GlideLocale object. 11 | * @returns The GlideLocale object. 12 | * @example var locale = GlideLocale.get(); 13 | */ 14 | get() {} 15 | /** 16 | * Returns the decimal separator. 17 | * @returns The decimal separator. 18 | * @example var locale = GlideLocale.get(); 19 | * var decimalSeparator = locale.getDecimalSeparator(); 20 | * gs.info( "The decimal separator is " + decimalSeparator); 21 | */ 22 | getDecimalSeparator() {} 23 | /** 24 | * Returns the grouping separator. 25 | * @returns The grouping separator. 26 | * @example var locale = GlideLocale.get();var groupingSeparator = locale.getGroupingSeparator(); 27 | * gs.info( "The grouping separator is " + groupingSeparator); 28 | */ 29 | getGroupingSeparator() {} 30 | } -------------------------------------------------------------------------------- /ES5/email_activity.js: -------------------------------------------------------------------------------- 1 | //defer email_activity.js 2 | function setEmailBody(id) { 3 | var iframeID = id + ".body"; 4 | var iframe = gel(iframeID); 5 | if (iframe) 6 | return; 7 | iframe = cel("iframe"); 8 | iframe.id = iframeID; 9 | iframe.width="100%"; 10 | iframe.frameBorder = "0"; 11 | Event.observe(iframe, "load", emailResizeObserved.bind(iframe), true); 12 | iframe.src = "email_display.do?email_id=" + id; 13 | iframe.email_id = id; 14 | var cellID = id + ".mail_cell"; 15 | var td = gel(cellID); 16 | if (!td) { 17 | alert("email_activity.js: TD missing for '" + cellID + "'"); 18 | return; 19 | } 20 | td.appendChild(iframe); 21 | } 22 | function emailResizeObserved() { 23 | adjustEmailHeight(this); 24 | } 25 | function adjustEmailHeight(frame) { 26 | frame.style.height = frame.contentWindow.document.body.scrollHeight + 'px'; 27 | if (isSafari || isChrome) { 28 | var table = gel(frame.email_id + ".detail"); 29 | if (table) 30 | table.style.width="100%"; 31 | } 32 | } -------------------------------------------------------------------------------- /ES6/GlideDocumentV3.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The GlideDocument class provides the ability to search a DOM element, a document, or a 3 | * JQuery element. 4 | * @class GlideDocumentV3 5 | * @typedef {Object} GlideDocumentV3 6 | */ 7 | class GlideDocumentV3 { 8 | constructor() {} 9 | /** 10 | * Returns a node found in the specified DOM based context or created from the HTML 11 | * context. 12 | * @param {String or Object} selector The selector expression 13 | * @param {String or Object} context (Optional) A DOM Element, document, or JQuery object to be searched. 14 | * @returns The node that matches the selector. 15 | */ 16 | getElement(selector, context) {} 17 | /** 18 | * Returns a node list found in the specified DOM based context or created if an HTML 19 | * context is specified. 20 | * @param {String or Object} selector The selector expression 21 | * @param {String or Object} context (Optional) A DOM Element, document, or JQuery object to be searched. 22 | * @returns A list of nodes that matches the selector. 23 | */ 24 | getElements(selector, context) {} 25 | } -------------------------------------------------------------------------------- /ES6/TransformResult.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides the result of a transformation run on time-series data. 3 | * @class TransformResult 4 | * @typedef {Object} TransformResult 5 | */ 6 | class TransformResult { 7 | constructor() {} 8 | /** 9 | * Returns an array of Data objects. Returns an error if no group was specified for the 10 | * transform. 11 | * @returns An array of Data objects, with each object corresponding to a group. 12 | */ 13 | byGroup() {} 14 | /** 15 | * Returns the transformed data with the specified label. 16 | * @param {String} label The label that identifies the data to be retrieved. 17 | * @returns The Data object with the transform results. 18 | */ 19 | getByLabel(label) {} 20 | /** 21 | * Returns a single Data object, or null if the result is empty. 22 | * @returns The Data object with the transform results. 23 | */ 24 | getData() {} 25 | /** 26 | * Returns the transformed data as an array. This method turns a Data object into an 27 | * array. 28 | * @returns The Data object formatted as an array. 29 | */ 30 | toArray() {} 31 | } -------------------------------------------------------------------------------- /ES6/GlideOAuthToken.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use the GlideOAuthToken methods for retrieving OAuth access token and information about 3 | * the access token. 4 | * @class GlideOAuthToken 5 | * @typedef {Object} GlideOAuthToken 6 | */ 7 | class GlideOAuthToken { 8 | constructor() {} 9 | /** 10 | * Retrieves the access token. 11 | * @returns The access token. 12 | */ 13 | getAccessToken() {} 14 | /** 15 | * Retrieves the sys_id of the token ID. 16 | * @returns The sys_id of the access token. 17 | */ 18 | getAccessTokenSysID() {} 19 | /** 20 | * Retrieves the lifespan of the access token in seconds. 21 | * @returns The lifespan. 22 | */ 23 | getExpiresIn() {} 24 | /** 25 | * Retrieves the lifespan of the access token in seconds. 26 | * @returns The refresh token. 27 | */ 28 | getRefreshToken() {} 29 | /** 30 | * Retrieves the sys_id of the refresh token. 31 | * @returns The sys_id of the refresh token. 32 | */ 33 | getRefreshTokenSysID() {} 34 | /** 35 | * Retrieves the scope, which is the amount of access granted by the access 36 | * token. 37 | * @returns The scope. 38 | */ 39 | getScope() {} 40 | } -------------------------------------------------------------------------------- /ES6/GlideUICompatibility.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The scoped GlideUICompatibility class provides the ability for scoped applications to 3 | * define their own minimum browser versions. This is done by creating system properties for the 4 | * scoped application. 5 | * @class GlideUICompatibility 6 | * @typedef {Object} GlideUICompatibility 7 | */ 8 | class GlideUICompatibility { 9 | /** 10 | * Creates a GlideUICompatibility object. 11 | * @param {String} scopeName The application's scope name 12 | */ 13 | constructor(scopeName) {} 14 | /** 15 | * Returns the terms "block" or "allow" based upon the browser version. 16 | * @returns Either block or allow 17 | * @example UICompatibility = new GlideUICompatibility(gs.getCurrentScopeName()); 18 | * var blockOrAllow = UICompatibility.getCompatibility(); 19 | * gs.info(blockOrAllow); 20 | */ 21 | getCompatibility() {} 22 | /** 23 | * Determines if the browser is not supported. 24 | * @returns True if the browser is not supported. 25 | * @example UICompatibility = new GlideUICompatibility(gs.getCurrentScopeName()); 26 | * var blocked = UICompatibility.isBlocked(); 27 | * gs.info(blocked); 28 | */ 29 | isBlocked() {} 30 | } -------------------------------------------------------------------------------- /ES6/GlideOAuthClientResponse.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use these methods for handling OAuth client responses. 3 | * @class GlideOAuthClientResponse 4 | * @typedef {Object} GlideOAuthClientResponse 5 | */ 6 | class GlideOAuthClientResponse { 7 | constructor() {} 8 | /** 9 | * Retrieves all of the response information, including instance information. 10 | * @returns The response information. 11 | */ 12 | getBody() {} 13 | /** 14 | * Retrieves the HTTP response content header from an external OAuth provider. 15 | * @returns The HTTP response header. 16 | */ 17 | getContentType() {} 18 | /** 19 | * Retrieves the error message if authentication is not successful. 20 | * @returns The error message. 21 | */ 22 | getErrorMessage() {} 23 | /** 24 | * Retrieves the HTTP response code from the external OAuth provider. 25 | * @returns The HTTP response code. 26 | */ 27 | getResponseCode() {} 28 | /** 29 | * Retrieves the error message if authentication is not successful. 30 | * @returns The response content. 31 | */ 32 | getResponseParameters() {} 33 | /** 34 | * Retrieves the refresh token. 35 | * @returns The refresh token. 36 | */ 37 | getToken() {} 38 | } -------------------------------------------------------------------------------- /ES6/GlideFilter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The Scoped GlideFilter API provides a method to determine if a record meets a specified 3 | * set of requirements. 4 | * @class GlideFilter 5 | * @typedef {Object} GlideFilter 6 | */ 7 | class GlideFilter { 8 | constructor() {} 9 | /** 10 | * The filter parameter is an encoded query string. 11 | * @param {GlideRecord} gr The GlideRecord to be evaluated. 12 | * @param {String} filter An encoded query string. 13 | * @param {Object} matchAll (Optional) If true and the encoded query string contains multiple conditions 14 | * then all conditions must be true for the method to return true. If false and the 15 | * encoded query string contains multiple conditions then only one condition needs to 16 | * be true for the method to return true. If the encoded query string has only one 17 | * condition, this parameter has no impact. 18 | * @returns True when the record meets the filter conditions. 19 | * @example var rec = new GlideRecord('incident'); 20 | * rec.query(); 21 | * var bool = true; 22 | * while(rec.next()) 23 | * { 24 | * bool = GlideFilter.checkRecord(rec, "active=true"); 25 | * gs.info("number "+ rec. number + " is " + bool); 26 | * } 27 | */ 28 | checkRecord(gr, filter, matchAll) {} 29 | } -------------------------------------------------------------------------------- /ES6/GlideTextReader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides the ability to read single lines from an input stream. Because an input stream 3 | * is used, it is not subject to the 5MB attachment size limit. 4 | * @class GlideTextReader 5 | * @typedef {Object} GlideTextReader 6 | */ 7 | class GlideTextReader { 8 | /** 9 | * Creates a scoped GlideTextReader object for the specified input stream. 10 | * @param {GlideScriptableInputStream} inputStream The input stream to be read. 11 | */ 12 | constructor(inputStream) {} 13 | /** 14 | * Returns the character encoding of the input stream. 15 | * @returns The character encoding of the input stream. 16 | */ 17 | getEncoding() {} 18 | /** 19 | * Returns a single line from the input stream and returns a string. Since this is working 20 | * off of a stream, it is not subject to the 5MB size limit. 21 | * @returns A single line of input up to the carriage return. Does not include the carriage 22 | * return. Returns null if there is no content. 23 | * @example var is = new GlideSysAttachment().getContentStream(attachmentSysId); 24 | * var reader = new GlideTextReader(is); 25 | * var ln = ' '; 26 | * while((ln = reader.readLine()) != null) { 27 | * gs.info(ln); 28 | * } 29 | */ 30 | readLine() {} 31 | } -------------------------------------------------------------------------------- /ES6/GlideURLV3.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides methods for manipulating a URI. 3 | * @class GlideURLV3 4 | * @typedef {Object} GlideURLV3 5 | */ 6 | class GlideURLV3 { 7 | /** 8 | * Creates an instance of the GlideURL class. 9 | * @param {String} contextPath A relative path for the URL. 10 | */ 11 | constructor(contextPath) {} 12 | /** 13 | * Adds a query string name-value pair to the URL. 14 | * @param {String} name Name of the query string parameter. 15 | * @param {String} value Query string value. 16 | * @returns The GlideURL 17 | * @example var gu = new GlideURL('incident.do'); 18 | * var url = gu.addParam('sys_id', '-1'); 19 | * 20 | */ 21 | addParam(name, value) {} 22 | /** 23 | * Get the entire context path and query string parameters as a single URI. 24 | * @param {Object} additionalParams A name-value pair object that contains parameters that are added to this URL 25 | * request only. These additional parameters are not saved to the GlideURL 26 | * object. 27 | * @returns The GlideURL with the specified additional parameters added to the end. 28 | */ 29 | getURL(additionalParams) {} 30 | /** 31 | * Reloads the current page URL. 32 | * @returns Method does not return a value 33 | */ 34 | refresh() {} 35 | } -------------------------------------------------------------------------------- /ES6/GlideSysListControl.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The scoped GlideSysListControl class allows you to determine if the New or Edit buttons 3 | * are displayed. 4 | * @class GlideSysListControl 5 | * @typedef {Object} GlideSysListControl 6 | */ 7 | class GlideSysListControl { 8 | /** 9 | * Instantiates a GlideSysListControl object. 10 | * @param {String} tableName Name of the table 11 | */ 12 | constructor(tableName) {} 13 | /** 14 | * Returns the sys_id for the control. 15 | * @returns sys_id of the control 16 | * @example var sysListCtrl = new GlideSysListControl("incident"); 17 | * var controlID = sysListCtrl.getControlID(); 18 | * gs.info(controlID); 19 | */ 20 | getControlID() {} 21 | /** 22 | * Returns true if the edit button is not displayed. 23 | * @returns True when the edit button is not displayed. 24 | * @example var sysListCtrl = new GlideSysListControl("incident"); 25 | * var isOmitted = sysListCtrl.isOmitEditButton(); 26 | * gs.info(isOmitted); 27 | */ 28 | isOmitEditButton() {} 29 | /** 30 | * Returns true when the New button is not displayed. 31 | * @returns True when the new button is not displayed. 32 | * @example var sysListCtrl = new GlideSysListControl("incident"); 33 | * var isOmitted = sysListCtrl.isOmitNewButton(); 34 | * gs.info(isOmitted); 35 | */ 36 | isOmitNewButton() {} 37 | } -------------------------------------------------------------------------------- /ES5/GlidePane.js: -------------------------------------------------------------------------------- 1 | //defer classes/GlidePane.js 2 | /** 3 | * Display a dialog that covers the entire window with some spacing around the dialog to make it look nice. 4 | * 5 | * To use: 6 | * 7 | * var d = new GlidePane(title, tablename, [element, completionCallback]) 8 | * d.render(); 9 | * 10 | * 'element' is currently ignored and the Pane is displayed so that it covers the current window. 11 | */ 12 | var GlidePane = Class.create(GlidePaneForm, { 13 | DIALOG_FORM: "glide_pane", 14 | initialize: function(title, tableName, element, onCompletionCallback) { 15 | GlidePaneForm.prototype.initialize.call(this, title, tableName, element, onCompletionCallback); 16 | }, 17 | _onLoaded: function() { 18 | var f = gel("dialog_form_poster"); 19 | f.action = this.tableName + '.do'; 20 | addHidden(f, 'sysparm_nameofstack', 'formDialog'); 21 | addHidden(f, 'sysparm_titleless', 'true'); 22 | addHidden(f, 'sysparm_is_dialog_form', 'true'); 23 | var sysId = this.getPreference('sys_id'); 24 | if (!sysId) 25 | sysId = ''; 26 | addHidden(f, 'sys_id', sysId); 27 | addHidden(f, 'sysparm_sys_id', sysId); 28 | this.isLoaded = true; 29 | for (id in this.parms) 30 | addHidden(f, id, this.parms[id]); 31 | f.submit(); 32 | }, 33 | type : function() { 34 | return "GlidePane"; 35 | } 36 | }); -------------------------------------------------------------------------------- /ES6/GlideServletResponse.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The GlideServletResponse API is used in processor scripts. 3 | * @class GlideServletResponse 4 | * @typedef {Object} GlideServletResponse 5 | */ 6 | class GlideServletResponse { 7 | constructor() {} 8 | /** 9 | * Sends a temporary redirect to the client. 10 | * @param {String} location The URL to receive the response. 11 | * @returns Method does not return a value 12 | */ 13 | sendRedirect(location) {} 14 | /** 15 | * Sets the MIME type of the response 16 | * @param {String} type The MIME type. 17 | * @returns Method does not return a value 18 | * @example g_response.setContentType('text/html;charset=UTF-8'); 19 | */ 20 | setContentType(type) {} 21 | /** 22 | * Sets a response header to the specified value. 23 | * @param {String} key Specifies the header. 24 | * @param {String} value The value to be assigned to the header. If the header exists, it is over 25 | * written. 26 | * @returns Method does not return a value 27 | * @example g_response.setHeader("host", "demonightlyus.service-now.com"); 28 | */ 29 | setHeader(key, value) {} 30 | /** 31 | * Sets the status code for the response. 32 | * @param {Number} status The status to be set. 33 | * @returns Method does not return a value 34 | * @example // set the status to okay 35 | * g_response.setStatus(200); 36 | */ 37 | setStatus(status) {} 38 | } -------------------------------------------------------------------------------- /ES5/ac_derived_field_support.js: -------------------------------------------------------------------------------- 1 | //defer ac_derived_field_support.js 2 | function refFieldChangeResponse(request, args) { 3 | if (request == null) 4 | return; 5 | var elementName = args[0]; 6 | var parts = elementName.split("."); 7 | parts.shift(); 8 | var sName = parts.join(".") +"."; 9 | var nodes = new Array(); 10 | if (args[1]) { 11 | var fields = args[1].split(','); 12 | nodes = setNodes(sName, fields, request); 13 | return; 14 | } 15 | jslog("************** WHAT ARE WE DOING HERE *********************"); 16 | } 17 | function setNodes(sName, array, request) { 18 | for (var i=0; i= this.MILLIS_IN_HOUR) { 25 | hours = parseInt(millis / this.MILLIS_IN_HOUR); 26 | millis = millis - (hours * this.MILLIS_IN_HOUR); 27 | } 28 | if (millis >= this.MILLIS_IN_MINUTE) { 29 | minutes = parseInt(millis / this.MILLIS_IN_MINUTE); 30 | millis = millis - (minutes * this.MILLIS_IN_MINUTE); 31 | } 32 | if (millis >= this.MILLIS_IN_SECOND) { 33 | seconds = parseInt(millis / this.MILLIS_IN_SECOND); 34 | millis = millis - (seconds * this.MILLIS_IN_SECOND); 35 | } 36 | milliseconds = parseInt(millis); 37 | return doubleDigitFormat(hours) + ":" + doubleDigitFormat(minutes) + ":" + doubleDigitFormat(seconds) + 38 | "." + tripleDigitFormat(milliseconds); 39 | }, 40 | type: "StopWatch" 41 | }); -------------------------------------------------------------------------------- /ES6/PAScorecard.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The PAScorecard API enables you to query information about Performance Analytics scorecards and 3 | * indicators. 4 | * @class PAScorecard 5 | * @typedef {Object} PAScorecard 6 | */ 7 | class PAScorecard { 8 | constructor() {} 9 | /** 10 | * Add a query parameter to filter the returned scores. 11 | * @param {String} parameter The parameter to set. For a detailed list of available parameters, see . PAScorecard parameters 12 | * . 13 | * @param {String} value The value to assign to the specified parameter. 14 | * @returns Method does not return a value 15 | * @example var sc = new SNC.PAScorecard(); //in a scoped app, do not use the SNC namespace 16 | * sc.addParam('uuid', 'fb007202d7130100b96d45a3ce6103b4'); // Number of open incidents 17 | * sc.addParam('breakdown', '0df47e02d7130100b96d45a3ce610399'); // by Priority 18 | * var result = sc.query(); 19 | * var json = sc.asJSON(); 20 | * for (var i = 0; i < result.length; i++) 21 | * gs.info(result[i].name + ': ' + result[i].value + ' ' + result[i].unit.display_value); 22 | */ 23 | addParam(parameter, value) {} 24 | /** 25 | * Returns the latest query result as a JSON string. 26 | * @returns A JSON representation of the query result. 27 | */ 28 | asJSON() {} 29 | /** 30 | * Performs a query based on the specified parameters and return the scorecard as an 31 | * object. 32 | * @returns The scorecard object. 33 | */ 34 | query() {} 35 | /** 36 | * Returns the latest query result as an object. 37 | * @returns The scorecard object from the last query. 38 | */ 39 | result() {} 40 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sn-js-lib 2 | ServiceNow JavaScript API Libraries 3 | Set your library location to either ES5 or ES6 depending on your IDE and preferences. 4 | The ES5 version is more complete, but some IDEs (such as VS Code) are not able to parse the ES5 libs. We're working on improving the completeness of the ES6 libs. 5 | 6 | More info: http://lib.snc.guru/ 7 | 8 | Hi! I'm Tim Woodruff, of SN Pro Tips; author of Learning ServiceNow and The ServiceNow Development Handbook. This ServiceNow JavaScript API library was adapted from something that Garrett Griffin put together in 2014. I found the libraries so massively useful, that I decided to build upon, add to, and update them throughout the last several years (with permission from Garrett) in order to make developing ServiceNow-centric code in my local IDE a lot easier. While I've done a lot of work on this over the last few years, much of the credit must surely go to Garrett for his hard work in starting this out. 9 | 10 | My Twitter (@TheTimWoodruff): https://twitter.com/TheTimWoodruff 11 | Garrett's Twitter (@SNC_GarrettNow): https://twitter.com/SNC_GarrettNow 12 | SN Pro Tips (blog): http://snprotips.com/ 13 | Learning ServiceNow: http://lsn.snc.guru/ 14 | The ServiceNow Development Handbook: http://handbook.snc.guru/ 15 | 16 | You can find documentation on how to import and use this library in your IDE, including common/standard keyboard shortcuts to make effective use of the JSDoc documentation in the libraries, at this link: http://lib.snc.guru/ 17 | 18 | 19 | The following people have made significant contributions to this project: 20 | -Tim Woodruff (TimothyWoodruff.com) 21 | -Garrett Griffin (@SNC_GarrettNow) 22 | -Breyton Barber (dev.breyton.barber@gmail.com) -------------------------------------------------------------------------------- /ES6/GlideNavigationV3.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides methods to control and refresh the navigator and main frame. 3 | * @class GlideNavigationV3 4 | * @typedef {Object} GlideNavigationV3 5 | */ 6 | class GlideNavigationV3 { 7 | constructor() {} 8 | /** 9 | * Redirects to a new URL. 10 | * @param {String} url The URL to be loaded. It can be any URL supported by the browser. 11 | * @param {String} target The frame to use. If omitted, opens in the current frame. 12 | * @returns Method does not return a value 13 | */ 14 | open(url, target) {} 15 | /** 16 | * Opens a popup window. 17 | * @param {String} url The URL to open. 18 | * @param {String} name The window name 19 | * @param {String} features A comma separated list of features for the popup window. 20 | * @param {Boolean} noStack True to append sysparm_stack=no to the url. This prevents weirdness when using 21 | * the form back button. 22 | * @returns The instance of the new window. 23 | */ 24 | openPopup(url, name, features, noStack) {} 25 | /** 26 | * Redirects to a record. The record will be displayed in the navigator. 27 | * @param {String} tableName The name of the table containing the record to be displayed. 28 | * @param {String} sys_id The sys_id of the record to be displayed. 29 | * @returns Method does not return a value 30 | */ 31 | openRecord(tableName, sys_id) {} 32 | /** 33 | * Refreshes the navigator display. 34 | * @returns Method does not return a value 35 | */ 36 | refreshNavigator() {} 37 | /** 38 | * Reloads the current frame. 39 | * @returns Method does not return a value 40 | */ 41 | reloadWindow() {} 42 | } -------------------------------------------------------------------------------- /ES5/AjaxOtherCompleter.js: -------------------------------------------------------------------------------- 1 | //defer classes/ajax/AJAXOtherCompleter.js 2 | class AJAXOtherCompleter extends AJAXCompleter { 3 | constructor(element, reference) { 4 | super(); 5 | AJAXCompleter.prototype.initialize.call(this, 'AC.' + reference, reference); 6 | this.className = "AJAXReferenceCompleter"; 7 | this.dirty = false; 8 | this.matched = false; 9 | this.fieldChanged = false; 10 | this.ignoreAJAX = false; 11 | this.type = null; 12 | this.refField = null; 13 | this.textValue = ""; 14 | this.invisibleTextValue = ""; 15 | this.savedTextValue = ""; 16 | this.savedInvisibleTextValue = ""; 17 | this.previousTextValue = ""; 18 | this.resultsStorage = new Object(); 19 | this.emptyResults = new Object(); 20 | this.oldFunctionJunk(); 21 | } 22 | 23 | setInvisibleField(f) { 24 | this.iField = f; 25 | this._setAC(f); 26 | } 27 | 28 | setField(f) { 29 | this.field = f; 30 | this.field.autocomplete = "off"; 31 | this._setAC(f); 32 | } 33 | 34 | setUpdateField(f) { 35 | this.updateField = f; 36 | this._setAC(f); 37 | } 38 | 39 | _setAC(field) { 40 | if (field) { 41 | field.ac = this; 42 | } 43 | } 44 | 45 | setType(type) { 46 | this.type = type; 47 | } 48 | 49 | setSavedText(textArray) { 50 | if (textArray[0] != null) { 51 | this.savedInvisibleTextValue = textArray[0]; 52 | } 53 | this.savedTextValue = textArray[1]; 54 | } 55 | 56 | getMenu() { 57 | return this.getDropDown(); 58 | } 59 | 60 | getUpdateField() { 61 | return this.updateField; 62 | } 63 | 64 | oldFunctionJunk() { 65 | this.isOTM = function() { 66 | return this.type == ONE_TO_MANY; 67 | }; 68 | this.getInvisibleField = function() { 69 | return this.iField; 70 | }; 71 | } 72 | } -------------------------------------------------------------------------------- /ES5/CustomEventManager.js: -------------------------------------------------------------------------------- 1 | //include classes/event/CustomEventManager.js 2 | var CustomEventManager = Class.create(GwtObservable, { 3 | trace: false, 4 | observe: function(eventName, fn){ 5 | if (this.trace) 6 | jslog("$CustomEventManager observing: " + eventName); 7 | this.on(eventName, fn); 8 | }, 9 | fire: function(eventName, args){ 10 | if (this.trace) 11 | jslog("$CustomEventManager firing: " + eventName + " args: " + arguments.length); 12 | return this.fireEvent.apply(this, arguments); 13 | }, 14 | fireTop: function(eventName, args){ 15 | if (this.trace) 16 | jslog("$CustomEventManager firing: " + eventName + " args: " + arguments.length); 17 | this.fireEvent.apply(this, arguments); 18 | var t = getTopWindow(); 19 | if (t != null && window != t) 20 | t.CustomEvent.fireEvent(eventName, args); 21 | }, 22 | fireAll: function(eventName, args) { 23 | if (this.trace) 24 | jslog("$CustomEventManager firing: " + eventName + " args: " + arguments.length); 25 | var t = getTopWindow(); 26 | if (t == null) { 27 | this.fireEvent.apply(this, arguments); 28 | return; 29 | } 30 | t.CustomEvent.fireEvent(eventName, args); 31 | for (var i = 0; i < t.length; i++) { 32 | if (!t[i]) 33 | continue; 34 | if (t[i].CustomEvent && typeof t[i].CustomEvent.fireEvent == "function") 35 | t[i].CustomEvent.fireEvent(eventName, args); 36 | } 37 | }, 38 | toString: function() { 39 | return 'CustomEventManager'; 40 | } 41 | }); 42 | var CustomEvent = new CustomEventManager(); -------------------------------------------------------------------------------- /ES6/ConnectionInfoProvider.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use ConnectionInfoProvider API to select connection information through the connection 3 | * alias. 4 | * @class ConnectionInfoProvider 5 | * @typedef {Object} ConnectionInfoProvider 6 | */ 7 | class ConnectionInfoProvider { 8 | /** 9 | * Uses ConnectionInfoProvider() to select connection information through the connection 10 | * alias. 11 | */ 12 | constructor() {} 13 | /** 14 | * This function retrieves a ConnectionInfo object identified by the given aliasID in the 15 | * current domain. 16 | * @param {String} aliasID The sys_id of a connection alias. 17 | * @returns Information about the connection. 18 | * @example var provider = new sn_cc.ConnectionInfoProvider(); 19 | * // get a jdbc connection in the current domain with the alias ID 20 | * // "6219afbf9f03320021dd7501942e70fc" 21 | * var connectionInfo = provider.getConnectionInfo("6219afbf9f03320021dd7501942e70fc"); 22 | */ 23 | getConnectionInfo(aliasID) {} 24 | /** 25 | * This function retrieves a ConnectionInfo object identified by the given aliasID for a 26 | * specific domain. 27 | * @param {String} aliasID The sys_id of a connection alias. 28 | * @param {String} domainID The sys_id of a domain or global. 29 | * @returns Connection information. 30 | * @example var provider = new sn_cc.ConnectionInfoProvider(); 31 | * // get a jdbc connection in the ACME domain with the alias ID 32 | * // "cd5923ff9f03320021dd7501942e70bb" 33 | * connectionInfo = provider.getConnectionInfoByDomain("cd5923ff9f03320021dd7501942e70bb", 34 | * "c90d4b084a362312013398f051272c0d"); 35 | */ 36 | getConnectionInfoByDomain(aliasID, domainID) {} 37 | } -------------------------------------------------------------------------------- /ES6/ConnectionInfo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use ConnectionInfo API to get connection attribute information through the connection 3 | * and credential alias. 4 | * @class ConnectionInfo 5 | * @typedef {Object} ConnectionInfo 6 | */ 7 | class ConnectionInfo { 8 | constructor() {} 9 | /** 10 | * Returns the value of a connection info attribute with the specified name. 11 | * @returns Method does not return a value 12 | * @example // get the same values using getAttribute 13 | * gs.info(connectionInfo.getAttribute("name")); 14 | * gs.info(connectionInfo.getAttribute("connection_url")); 15 | * 16 | */ 17 | getAttribute() {} 18 | /** 19 | * Returns the value of credential attributes for a specified connection. 20 | * @returns Method does not return a value 21 | * @example // get credential attributes 22 | * gs.info(connectionInfo.getCredentialAttribute("user_name")); 23 | * gs.info(connectionInfo.getCredentialAttribute("password")); 24 | * 25 | */ 26 | getCredentialAttribute() {} 27 | /** 28 | * Returns the connection attributes as a collection of key-value pairs. 29 | * @returns Method does not return a value 30 | * @example // get data map 31 | * var datamap = connectionInfo.getDataMap(); 32 | * gs.info(datamap["name"]); 33 | * gs.info(datamap["connection_url"]); 34 | * 35 | */ 36 | getDataMap() {} 37 | /** 38 | * Returns the extended attributes as a collection of key-value pairs. 39 | * @returns Method does not return a value 40 | * @example // get extended attributes 41 | * var extendedAttributes = connection.getExtendedAttributes(); 42 | * gs.info(extendedAttributes["name1"]); 43 | * } 44 | * 45 | */ 46 | getExtendedAttributes() {} 47 | } -------------------------------------------------------------------------------- /ES5/GlideClientCache.js: -------------------------------------------------------------------------------- 1 | //defer classes/GlideClientCache.js 2 | var GlideClientCacheEntry = Class.create({ 3 | initialize: function(value) { 4 | this.value = value; 5 | this.bump(); 6 | }, 7 | bump: function() { 8 | this.stamp = new Date().getTime(); 9 | } 10 | }); 11 | var GlideClientCache = Class.create({ 12 | _DEFAULT_SIZE : 50, 13 | initialize: function(maxEntries) { 14 | if (maxEntries) 15 | this.maxEntries = maxEntries; 16 | else 17 | this.maxEntries = this._DEFAULT_SIZE; 18 | this._init('default'); 19 | }, 20 | _init : function(stamp) { 21 | this._cache = new Object(); 22 | this._stamp = stamp; 23 | }, 24 | put: function(key, value) { 25 | var entry = new GlideClientCacheEntry(value); 26 | this._cache[key] = entry; 27 | this._removeEldest(); 28 | }, 29 | get : function(key) { 30 | var entry = this._cache[key]; 31 | if (!entry) 32 | return null; 33 | entry.bump(); 34 | return entry.value; 35 | }, 36 | stamp : function(stamp) { 37 | if (stamp == this._stamp) 38 | return; 39 | this._init(stamp); 40 | }, 41 | _removeEldest : function() { 42 | var count = 0; 43 | var eldest = null; 44 | var eldestKey = null; 45 | for (key in this._cache) { 46 | count++; 47 | var current = this._cache[key]; 48 | if (eldest == null || eldest.stamp > current.stamp) { 49 | eldestKey = key; 50 | eldest = current; 51 | } 52 | } 53 | if (count <= this.maxEntries) 54 | return; 55 | if (eldest != null) 56 | delete this._cache[key]; 57 | } 58 | }); -------------------------------------------------------------------------------- /ES5/CurrencyFormat.js: -------------------------------------------------------------------------------- 1 | var CurrencyFormat = Class.create(); 2 | /* 3 | * Formats one or more prices in a single ajax call to CurrencyAjaxProcessor 4 | * Upon completion, calls the specified callback function, passing a map of formatted prices as arg0 5 | * example usage: 6 | * var cf = new CurrencyFormat(this.priceResponse.bind(this)); 7 | * cf.addPrice('unit_price', 1000); 8 | * cf.addPrice('total_price', 123456); 9 | * cf.formatPrices(); 10 | * 11 | * Upon comnpletion of the asychronous ajax call, the provided callback function will be invoked 12 | * and handed off a map in the form: 13 | * 14 | * responsemap = { unit_price : "$1,000.00", total_price : "$123,456.00" } 15 | * 16 | * 17 | */ 18 | CurrencyFormat.prototype = { 19 | _PROCESSOR : "com.glideapp.servicecatalog.CurrencyAjaxProcessor", 20 | initialize: function(callBack) { 21 | this._callBack = callBack; 22 | this._map = new Object(); 23 | }, 24 | addPrice: function (key, value) { 25 | this._map[key] = value + ''; 26 | }, 27 | formatPrices: function () { 28 | var ajax = new GlideAjax(this._PROCESSOR); 29 | ajax.addParam("sysparm_action", "calcprice"); 30 | for (key in this._map) 31 | ajax.addParam("sysparm_price_" + key, this._map[key]); 32 | ajax.getXML(this.handleResponse.bind(this)); 33 | }, 34 | handleResponse: function(request) { 35 | responseMap = new Object(); 36 | var xml = request.responseXML; 37 | for (key in this._map) { 38 | var items = xml.getElementsByTagName("sysparm_price_" + key); 39 | if (items.length == 1) { 40 | var price = items[0].getAttribute("price"); 41 | responseMap[key] = price; 42 | } 43 | } 44 | this._callBack.call(this, responseMap); 45 | } 46 | } -------------------------------------------------------------------------------- /ES6/GlideScriptedProcessor.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ServiceNow 3 | * processors are equivalent to Java servlets. 4 | * @class GlideScriptedProcessor 5 | * @typedef {Object} GlideScriptedProcessor 6 | */ 7 | class GlideScriptedProcessor { 8 | constructor() {} 9 | /** 10 | * Redirects to the specified URL. 11 | * @param {String} url the destination URL 12 | * @returns Method does not return a value 13 | * @example //Do whatever processing you need and redirect to the homepage 14 | * g_processor.redirect("/navpage.do") 15 | */ 16 | redirect(url) {} 17 | /** 18 | * Encodes an object as a JSON string and writes it to the current URL. 19 | * @param {Object} o The object to encode to a JSON string. 20 | * @returns Method does not return a value 21 | * @example var map = {"key1":"value1","key2":"value2"}; 22 | * g_processor.writeJSON(map); 23 | */ 24 | writeJSON(o) {} 25 | /** 26 | * Writes the specified string to the current URL in the specified 27 | * character-encoding. 28 | * @param {String} contentType Sets the content type of the response sent to the client, if the response has 29 | * not been committed, and may include a character-encoding specification. 30 | * @param {String} s The string to write. 31 | * @returns Method does not return a value 32 | * @example var name = g_request.getParameter("name"); 33 | * g_processor.writeOutput("text/plain", "Hello " + name); 34 | */ 35 | writeOutput(contentType, s) {} 36 | /** 37 | * Writes the specified string to the current URL. 38 | * @param {String} s The string to write. 39 | * @returns Method does not return a value 40 | * @example var name = g_request.getParameter("name"); 41 | * g_processor.writeOutput("Hello " + name); 42 | */ 43 | writeOutput(s) {} 44 | } -------------------------------------------------------------------------------- /ES5/TemplateRecord.js: -------------------------------------------------------------------------------- 1 | //defer classes/TemplateRecord.js 2 | var TemplateRecord = Class.create({ 3 | NAME: "name", 4 | VALUE: "value", 5 | ITEM: "item", 6 | DEPENDENT: "dependent", 7 | initialize: function(sysID) { 8 | this.sysID = sysID; 9 | }, 10 | apply: function() { 11 | var ga = new GlideAjax('AjaxClientHelper'); 12 | ga.addParam('sysparm_name','getValues'); 13 | ga.addParam('sysparm_sys_id',this.sysID); 14 | ga.getXML(this._applyResponse.bind(this)); 15 | }, 16 | _applyResponse : function(response) { 17 | if (!response || !response.responseXML) 18 | return; 19 | this.template = response.responseXML; 20 | this.applyRecord(); 21 | }, 22 | applyRecord: function() { 23 | var fa = g_form.getEditableFields(); 24 | var fao = new Object(); 25 | for (var i = 0; i < fa.length; i++) 26 | fao[fa[i]] = fa[i]; 27 | var items = this.template.getElementsByTagName(this.ITEM); 28 | for (var i = 0; i < items.length; i++) { 29 | var item = items[i]; 30 | var name = item.getAttribute(this.NAME); 31 | if (!fao[name]) 32 | continue; 33 | this.applyItem(name, item.getAttribute(this.VALUE)); 34 | } 35 | }, 36 | applyItem: function(element, value) { 37 | if (value == null || value == 'null') 38 | return; 39 | g_form.setTemplateValue(element, value); 40 | } 41 | }); 42 | TemplateRecord.save = function(id) { 43 | var fields = g_form.getEditableFields(); 44 | var f = g_form.getFormElement(); 45 | addHidden(f, 'sysparm_template_editable', fields.join()); 46 | gsftSubmit(id); 47 | }/* 48 | * To change this template, choose Tools | Templates 49 | * and open the template in the editor. 50 | */ 51 | 52 | 53 | -------------------------------------------------------------------------------- /ES6/CatalogItemVariable.js: -------------------------------------------------------------------------------- 1 | /** 2 | * CatalogItemVariable API enables you to create and modify service 3 | * catalog item variables using scripts. 4 | * @class CatalogItemVariable 5 | * @typedef {Object} CatalogItemVariable 6 | */ 7 | class CatalogItemVariable { 8 | constructor() {} 9 | /** 10 | * Insert the defined catalog item variable. 11 | * @param {Boolean} standardUpdate Set to true to enable the running of engines and workflow. 12 | * @returns Return the sys_id of the inserted variable record. 13 | */ 14 | create(standardUpdate) {} 15 | /** 16 | * Deletes the defined catalog item variable. 17 | * @param {Boolean} standardUpdate Set to true to enable the running of engines and workflow. 18 | * @returns Method does not return a value 19 | */ 20 | deleteRecord(standardUpdate) {} 21 | /** 22 | * Returns a mapping of catalog item variable attribute values. 23 | * @param {Object} columns Specify the set of columns that you would like the values for. 24 | * @param {Boolean} standardUpdate Set to true to enable the running of engines and workflow. 25 | * @returns An object mapping column names to values. 26 | */ 27 | read(columns, standardUpdate) {} 28 | /** 29 | * Defines attribute values for the specified catalog item variable. 30 | * @param {Object} attributes An object mapping column names to values. 31 | * @returns Method does not return a value 32 | */ 33 | setAttributes(attributes) {} 34 | /** 35 | * Updates the current catalog item variable with set values. 36 | * @param {Object} columnValues An object mapping column names to values. 37 | * @param {Boolean} standardUpdate Set to true to enable the running of engines and workflow. 38 | * @returns Method does not return a value 39 | */ 40 | update(columnValues, standardUpdate) {} 41 | } -------------------------------------------------------------------------------- /ES6/CatalogItemVariableSet.js: -------------------------------------------------------------------------------- 1 | /** 2 | * CatalogItemVariableSet API enables you to create and modify service 3 | * catalog item variable sets using scripts. 4 | * @class CatalogItemVariableSet 5 | * @typedef {Object} CatalogItemVariableSet 6 | */ 7 | class CatalogItemVariableSet { 8 | constructor() {} 9 | /** 10 | * Inserts the defined catalog item variable set. 11 | * @param {Boolean} standardUpdate Set to true to enable the running of engines and workflow. 12 | * @returns Return the sys_id of the inserted variable record. 13 | */ 14 | create(standardUpdate) {} 15 | /** 16 | * Deletes the defined catalog item variable. 17 | * @param {Boolean} standardUpdate Set to true to enable the running of engines and workflow. 18 | * @returns Method does not return a value 19 | */ 20 | deleteRecord(standardUpdate) {} 21 | /** 22 | * Returns a mapping of catalog item variable set attribute values. 23 | * @param {Object} columns Specify the set of columns that you would like the values for. 24 | * @param {Boolean} standardUpdate Set to true to enable the running of engines and workflow. 25 | * @returns An object mapping column names to values. 26 | */ 27 | read(columns, standardUpdate) {} 28 | /** 29 | * Defines attribute values for this catalog item variable set. 30 | * @param {Object} attributes An object mapping column names to values. 31 | * @returns Method does not return a value 32 | */ 33 | setAttributes(attributes) {} 34 | /** 35 | * Updates the current catalog item variable set with set values. 36 | * @param {Object} columnValues An object mapping column names to values. 37 | * @param {Boolean} standardUpdate Set to true to enable the running of engines and workflow. 38 | * @returns Method does not return a value 39 | */ 40 | update(columnValues, standardUpdate) {} 41 | } -------------------------------------------------------------------------------- /ES5/AjaxReferenceChoice.js: -------------------------------------------------------------------------------- 1 | //defer classes/ajax/AJAXReferenceChoice.js 2 | /* 3 | * Handles the client side updating of "choice type" reference fields which may 4 | * potentially need to reset their list of choices if they A) have an advanced reference qualifier 5 | * and B) you change one of those fields on the client side 6 | */ 7 | var AJAXReferenceChoice = Class.create(AJAXReferenceCompleter, { 8 | addSysParms: function() { 9 | var sp = "sysparm_processor=PickList" + 10 | "&sysparm_name=" + this.elementName + 11 | "&sysparm_timer=" + this.timer + 12 | "&sysparm_max=" + this.max + 13 | "&sysparm_chars=" + encodeText(this.searchChars); 14 | return sp; 15 | }, 16 | ajaxRequest : function() { 17 | var url = ""; 18 | url += this.addSysParms(); 19 | url += this.addDependentValue(); 20 | url += this.addRefQualValues(); 21 | url += this.addTargetTable(); 22 | url += this.addAdditionalValues(); 23 | url += this.addAttributes("ac_"); 24 | url += "&sysparm_max=250"; 25 | serverRequestPost("xmlhttp.do", url, this.ajaxResponse.bind(this)); 26 | }, 27 | onBlur : function() {}, 28 | onFocus : function() {}, 29 | ajaxResponse: function(response) { 30 | if (!response.responseXML.documentElement) { 31 | this.isResolvingFlag = false; 32 | return; 33 | } 34 | var currentValue = this.element.value; 35 | this.element.options.length = 0; 36 | var items = response.responseXML.getElementsByTagName("item"); 37 | var s = ""; 38 | for (var i = 0; i < items.length; i++) { 39 | var item = items[i]; 40 | var id = item.getAttribute('value'); 41 | var l = item.getAttribute('name'); 42 | var selected = id == currentValue; 43 | addOption(this.element, id, l, selected) ; 44 | } 45 | } 46 | }); -------------------------------------------------------------------------------- /ES6/StandardCredentialsProvider.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use StandardCredentialsProvider API to retrieve credential information. 3 | * @class StandardCredentialsProvider 4 | * @typedef {Object} StandardCredentialsProvider 5 | */ 6 | class StandardCredentialsProvider { 7 | /** 8 | * Use StardardCredentialsProvider() to retrieve credential information. 9 | */ 10 | constructor() {} 11 | /** 12 | * This function retrieves a credential object identified by the given sys ID. 13 | * @param {String} sys A string representing the sys ID of the credential record. 14 | * @returns A credential. 15 | * @example var provider = new sn_cc.StandardCredentialsProvider(); 16 | * var credentials = provider.getCredentials(["ssh"]); 17 | * for (var i = 0; i < credentials.length; i++) { 18 | * var credential = credentials[i]; 19 | * gs.info(credential.getAttribute("name")); 20 | * } 21 | * 22 | */ 23 | getCredentialByID(sys) {} 24 | /** 25 | * This function returns an array of all credentials that match the given types and 26 | * tags. 27 | * @param {String} types Types is an array of credential type names. For example, ["ssh", 28 | * "windows"]Note: If types are null or empty, any match returns a credential. If 29 | * types are specified, the credentials whose type matches one of the types 30 | * returns. 31 | * @param {String} handles Handles is a comma-separated list of handle names. For example, 32 | * "ssh,jdbc" 33 | * @returns Information about the ConnInfo... 34 | * @example var provider = new sn_cc.StandardCredentialsProvider(); 35 | * var credentials = provider.getCredentials(["ssh"]); 36 | * for (var i = 0; i < credentials.length; i++) { 37 | * var credential = credentials[i]; 38 | * gs.info(credential.getAttribute("name")); 39 | * } 40 | * 41 | */ 42 | getCredentials(types, handles) {} 43 | } -------------------------------------------------------------------------------- /ES6/GlideURI.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The GlideURI class is a utility class for handling the URI parameter. The GlideURI class 3 | * is available in scoped and global scripts. 4 | * @class GlideURI 5 | * @typedef {Object} GlideURI 6 | */ 7 | class GlideURI { 8 | /** 9 | * Instantiates a GlideURI object. 10 | */ 11 | constructor() {} 12 | /** 13 | * Returns the specified parameter. 14 | * @param {String} name The parameter name. 15 | * @returns The URI for the specified parameter. 16 | * @example var gURI = new GlideURI(); 17 | * gURI.set('sysparm_query', 'priority=2^active=true' ); 18 | * var fileString = gURI.get('sysparm_query'); 19 | * gs.info(fileString); 20 | */ 21 | get(name) {} 22 | /** 23 | * Returns the file name portion of the URI. 24 | * @returns The file name portion of the URI. 25 | * @example var gURI = new GlideURI(); 26 | * var fileString = gURI.getFileFromPath(); 27 | * gs.info(fileString); 28 | */ 29 | getFileFromPath() {} 30 | /** 31 | * Sets the specified parameter to the specified value. 32 | * @param {String} name The parameter name. 33 | * @param {String} value The value. 34 | * @returns Method does not return a value 35 | * @example var gURI = new GlideURI(); 36 | * gURI.set('sysparm_query', 'priority=2^active=true' ); 37 | * var fileString = gURI.get('sysparm_query'); 38 | * gs.info(fileString); 39 | */ 40 | set(name, value) {} 41 | /** 42 | * Reconstructs the URI string and performs the proper URL encoding by converting 43 | * non-valid characters to their URL code. For example, converting & to '%26'. 44 | * @param {String} path The base portion of the system URL to which the URI is appended. 45 | * @returns The URL. 46 | * @example fileString = gURI.toString('https://<your instance>.service-now.com/navpage.do'); 47 | */ 48 | toString(path) {} 49 | } -------------------------------------------------------------------------------- /ES6/CatalogItemVariableSetM2M.js: -------------------------------------------------------------------------------- 1 | /** 2 | * CatalogItemVariableSetM2M API enables you to create and modify 3 | * service catalog item variable set many-to-many (M2Ms) using scripts. 4 | * @class CatalogItemVariableSetM2M 5 | * @typedef {Object} CatalogItemVariableSetM2M 6 | */ 7 | class CatalogItemVariableSetM2M { 8 | constructor() {} 9 | /** 10 | * Inserts the defined catalog item variable set M2M. 11 | * @param {Boolean} standardUpdate Set to true to enable the running of engines and workflow. 12 | * @returns Return the sys_id of the inserted variable record. 13 | */ 14 | create(standardUpdate) {} 15 | /** 16 | * Deletes the defined catalog item variable set M2M. 17 | * @param {Boolean} standardUpdate Set to true to enable the running of engines and workflow. 18 | * @returns Method does not return a value 19 | */ 20 | deleteRecord(standardUpdate) {} 21 | /** 22 | * Returns a mapping of catalog item variable set M2M attribute values. 23 | * @param {Object} columns Specify the set of columns that you would like the values for. 24 | * @param {Boolean} standardUpdate Set to true to enable the running of engines and workflow. 25 | * @returns An object mapping column names to values. 26 | */ 27 | read(columns, standardUpdate) {} 28 | /** 29 | * Defines attribute values for this catalog item variable set M2M. 30 | * @param {Object} attributes An object mapping column names to values. 31 | * @returns Method does not return a value 32 | */ 33 | setAttributes(attributes) {} 34 | /** 35 | * Updates the current catalog item variable set M2M with set values. 36 | * @param {Object} columnValues An object mapping column names to values. 37 | * @param {Boolean} standardUpdate Set to true to enable the running of engines and workflow. 38 | * @returns Method does not return a value 39 | */ 40 | update(columnValues, standardUpdate) {} 41 | } -------------------------------------------------------------------------------- /ES6/DataBuilder.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use the DataBuilder class to create a series of data points for a metric. Use the 3 | * sn_clotho.Client.put() method to save the values. 4 | * @class DataBuilder 5 | * @typedef {Object} DataBuilder 6 | */ 7 | class DataBuilder { 8 | /** 9 | * Creates an instance of the DataBuilder class. 10 | * @param {Object} glideRecord GlideRecord from which to obtain the domain. 11 | * @param {String} metric The field name of the metric. 12 | */ 13 | constructor(glideRecord, metric) {} 14 | /** 15 | * Add a series of data points to the DataBuilder object. Each data point is a time stamp 16 | * and a value. 17 | * @param {GlideDateTime} start The time stamp for the first data point. Subsequent time stamps are calculated 18 | * using the retention policy collection period. 19 | * @param {Array} value An array of numbers. 20 | * @returns The same DataBuilder object. 21 | * @example 22 | * var points = [7,0.5,273]; 23 | * var dataBuilder = new sn_clotho.DataBuilder(gr, 'cpu_percentage'); 24 | * // this creates a GlideDateTime object set to the current date and time 25 | * var time = new GlideDateTime(); 26 | * dataBuilder.add(time, points); 27 | */ 28 | add(start, value) {} 29 | /** 30 | * Adds a data point to the DataBuilder object. Each data point is a time stamp and a 31 | * value. This method does not save the data point in the metric. Use the 32 | * sn_clotho.Client.put() method to save the values. 33 | * @param {GlideDateTime} start The time stamp for the data point. 34 | * @param {Number} value The value of the data point. 35 | * @returns The DataBuilder object. 36 | * @example var dataBuilder = new sn_clotho.DataBuilder(gr, 'cpu_percentage'); 37 | * // this creates a GlideDateTime object set to the current date and time 38 | * var time = new GlideDateTime(); 39 | * dataBuilder.add(time, 0.6); 40 | */ 41 | add(start, value) {} 42 | } -------------------------------------------------------------------------------- /ES6/XMLNodeIterator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The scoped XMLNodeIterator class allows you to iterate through a node of a XML 3 | * document. 4 | * @class XMLNodeIterator 5 | * @typedef {Object} XMLNodeIterator 6 | */ 7 | class XMLNodeIterator { 8 | constructor() {} 9 | /** 10 | * Returns true if the iteration has more elements. 11 | * @returns True if the iteration has more elements. 12 | * @example var xmlString = "<test>" + 13 | * " <one>" + 14 | * " <two att=\"xxx\">abcd1234</two>" + 15 | * " <three boo=\"yah\" att=\"yyy\">1234abcd</three>" + 16 | * " <two>another</two>" + 17 | * " </one>" + 18 | * " <number>1234</number>" + 19 | * "</test>"; 20 | * var xmlDoc = new XMLDocument2(); 21 | * xmlDoc.parseXML(xmlString); 22 | * var node = xmlDoc.getNode('//one'); 23 | * var iter= node.getChildNodeIterator(); 24 | * gs.info(iter.hasNext()); 25 | */ 26 | hasNext() {} 27 | /** 28 | * Gets the next element in the iteration. The returned element may be a #text node for 29 | * the spaces/tabs if XML is "pretty formatted". 30 | * @returns The next element in the iteration. 31 | * @example var xmlString = "<test>" + 32 | * " <one>" + 33 | * " <two att=\"xxx\">abcd1234</two>" + 34 | * " <three boo=\"yah\" att=\"yyy\">1234abcd</three>" + 35 | * " <two>another</two>" + 36 | * " </one>" + 37 | * " <number>1234</number>" + 38 | * "</test>"; 39 | * var xmlDoc = new XMLDocument2(); 40 | * xmlDoc.parseXML(xmlString); 41 | * var node = xmlDoc.getNode('//one'); 42 | * var iter= node.getChildNodeIterator(); 43 | * while(iter.hasNext()) { 44 | * var n = iter.next(); 45 | * gs.info('Node name: ' + n.getNodeName()); 46 | * gs.info('Node value: ' + n.getNodeValue()); 47 | * } 48 | */ 49 | next() {} 50 | } -------------------------------------------------------------------------------- /ES5/User.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This replicates the outline of the User object for help in autocompletion. 3 | * http://wiki.service-now.com/index.php?title=Getting_a_User_Object 4 | * http://wiki.service-now.com/index.php?title=The_g_user_Object 5 | * http://www.servicenowguru.com/scripting/user-object-cheat-sheet/ 6 | */ 7 | function User() { 8 | 9 | //------------------------------------------------------------------------------// 10 | //--------------------------Descriptive Functions-------------------------------// 11 | //------------------------------------------------------------------------------// 12 | 13 | this.getFirstName = function () { }; 14 | this.getLastName = function () { }; 15 | this.getEmail = function () { }; 16 | this.getDepartmentID = function () { }; 17 | this.getCompanyID = function () { }; 18 | this.getCompanyRecord = function () { }; 19 | this.getLanguage = function () { }; 20 | this.getLocation = function () { }; 21 | this.getDomainID = function () { }; 22 | this.getDomainDisplayValue = function () { }; 23 | this.getManagerID = function () { }; 24 | this.getUserByID = function () { }; 25 | 26 | //------------------------------------------------------------------------------// 27 | //--------------------Security and Group Functions------------------------------// 28 | //------------------------------------------------------------------------------// 29 | this.getMyGroups = function () { }; 30 | //this.isMemberOf = function(String) { }; //server-side only 31 | this.hasRole = function (String) { }; 32 | this.hasRoles = function () { }; // Boolean Function 33 | 34 | this.getRecord = function () {return new GlideRecord();}; 35 | }; 36 | 37 | 38 | function GUser() { 39 | 40 | this.userName = ''; 41 | this.firstName = ''; 42 | this.lastName = ''; 43 | this.userID = ''; 44 | this.hasRole = function (String) { }; 45 | this.hasRoles = function (String, String, String) { }; // Boolean Function 46 | }; 47 | 48 | var g_user = new GUser(); -------------------------------------------------------------------------------- /ES5/Class.js: -------------------------------------------------------------------------------- 1 | var Class = (function() { 2 | var d = (function() { 3 | for (var e in { 4 | toString: 1 5 | }) { 6 | if (e === "toString") { 7 | return false 8 | } 9 | } 10 | return true 11 | } 12 | )(); 13 | function a() {} 14 | function b() { 15 | var h = null 16 | , g = $A(arguments); 17 | if (Object.isFunction(g[0])) { 18 | h = g.shift() 19 | } 20 | function e() { 21 | this.initialize.apply(this, arguments) 22 | } 23 | Object.extend(e, Class.Methods); 24 | e.superclass = h; 25 | e.subclasses = []; 26 | if (h) { 27 | a.prototype = h.prototype; 28 | e.prototype = new a; 29 | h.subclasses.push(e) 30 | } 31 | for (var f = 0, j = g.length; f < j; f++) { 32 | e.addMethods(g[f]) 33 | } 34 | if (!e.prototype.initialize) { 35 | e.prototype.initialize = Prototype.emptyFunction 36 | } 37 | e.prototype.constructor = e; 38 | return e 39 | } 40 | function c(l) { 41 | var g = this.superclass && this.superclass.prototype 42 | , f = Object.keys(l); 43 | if (d) { 44 | if (l.toString != Object.prototype.toString) { 45 | f.push("toString") 46 | } 47 | if (l.valueOf != Object.prototype.valueOf) { 48 | f.push("valueOf") 49 | } 50 | } 51 | for (var e = 0, h = f.length; e < h; e++) { 52 | var k = f[e] 53 | , j = l[k]; 54 | if (g && Object.isFunction(j) && j.argumentNames()[0] == "$super") { 55 | var m = j; 56 | j = (function(i) { 57 | return function() { 58 | return g[i].apply(this, arguments) 59 | } 60 | } 61 | )(k).wrap(m); 62 | j.valueOf = (function(i) { 63 | return function() { 64 | return i.valueOf.call(i) 65 | } 66 | } 67 | )(m); 68 | j.toString = (function(i) { 69 | return function() { 70 | return i.toString.call(i) 71 | } 72 | } 73 | )(m) 74 | } 75 | this.prototype[k] = j 76 | } 77 | return this 78 | } 79 | return { 80 | create: b, 81 | Methods: { 82 | addMethods: c 83 | } 84 | } 85 | } 86 | )(); -------------------------------------------------------------------------------- /ES6/Data.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Data object contains the results of transform performed by a 3 | * sn_clotho.Client.transform() method. 4 | * @class Data 5 | * @typedef {Object} Data 6 | */ 7 | class Data { 8 | constructor() {} 9 | /** 10 | * Returns the end time for data in the Data object. 11 | * @returns The end of the time period. 12 | */ 13 | getEnd() {} 14 | /** 15 | * Returns the label assigned by the 16 | * sn_clotho.ClothoTransform.label() method. 17 | * @returns The label assigned to the data. 18 | */ 19 | getLabel() {} 20 | /** 21 | * Returns the name of the metric of the data series. Returns null when the data object is 22 | * associated with multiple data series. 23 | * @returns Name of the metric field. Returns null when the data object is associated with 24 | * multiple data series. 25 | */ 26 | getMetricName() {} 27 | /** 28 | * Returns the time period in milliseconds. 29 | * @returns The elapsed time in seconds. 30 | */ 31 | getPeriod() {} 32 | /** 33 | * Returns the start time for data in the Data object. 34 | * @returns The time for the first data point. 35 | */ 36 | getStart() {} 37 | /** 38 | * Returns the subject of the data series. Returns null when the data object is associated 39 | * with multiple data series. 40 | * @returns The subject field value of the subject GlideRecord. This is generally the 41 | * sys_id of the subject GlideRecord. 42 | */ 43 | getSubject() {} 44 | /** 45 | * Returns the name of the table assigned in the DataSelector class constructor. Returns 46 | * null when the data object is associated with multiple data series. 47 | * @returns Table name. Returns null when the data object is associated with multiple data 48 | * series. 49 | */ 50 | getTableName() {} 51 | /** 52 | * Returns an array of values. 53 | * @returns An array of numbers. 54 | */ 55 | getValues() {} 56 | /** 57 | * Returns the number of values in the Data object. 58 | * @returns The number of values in the object. 59 | */ 60 | size() {} 61 | } -------------------------------------------------------------------------------- /ES5/AutoComplete.js: -------------------------------------------------------------------------------- 1 | //defer classes/AutoComplete.js 2 | var AutoComplete = Class.create({ 3 | initialize: function() { 4 | this.processor = "AutoComplete"; 5 | this.table = null; 6 | this.column = null; 7 | this.query = null; 8 | this.typedChars = ""; 9 | this.input = null; 10 | this.select = null; 11 | this.timeout = null; 12 | this.keyDelay = 500; 13 | }, 14 | setTable: function(name) { 15 | this.table = name; 16 | }, 17 | setColumn: function(name) { 18 | this.column = name; 19 | }, 20 | setQuery: function(query) { 21 | this.query = query; 22 | }, 23 | setSelect: function(o) { 24 | this.select = gel(o); // I like writing jello 25 | }, 26 | setInput: function(o) { 27 | this.input = gel(o); 28 | }, 29 | onKeyUp: function(event) { 30 | if (this.timeout) 31 | clearTimeout(this.timeout); 32 | this.timeout = setTimeout(this._onKeyUp.bind(this), this.keyDelay); 33 | }, 34 | _onKeyUp: function() { 35 | this.timeout = null; 36 | this.typedChars = this.input.value; 37 | this.ajaxRequest(); 38 | }, 39 | ajaxRequest: function(urlParameters) { 40 | var ajax = new GlideAjax(this.processor); 41 | ajax.addParam("sysparm_chars", this.typedChars); 42 | ajax.addParam("sysparm_name", this.table + "." + this.column); 43 | if (this.query) 44 | ajax.addParam("sysparm_query", this.query); 45 | ajax.getXML(this.ajaxResponse.bind(this)); 46 | }, 47 | ajaxResponse: function(request) { 48 | if (!request.responseXML.documentElement) 49 | return; 50 | this.populateSelect(request.responseXML.documentElement); 51 | }, 52 | populateSelect: function(xml) { 53 | this.select.options.length = 0; 54 | var items = xml.getElementsByTagName("item"); 55 | for (var i = 0; i < items.length; i++ ) { 56 | var item = items[i]; 57 | var o = new Option(item.getAttribute('label'), item.getAttribute('sys_id')); 58 | this.select.options[this.select.options.length] = o; 59 | } 60 | } 61 | }); -------------------------------------------------------------------------------- /ES6/GlideServletRequest.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The GlideServletRequest API is used in processor scripts. 3 | * @class GlideServletRequest 4 | * @typedef {Object} GlideServletRequest 5 | */ 6 | class GlideServletRequest { 7 | constructor() {} 8 | /** 9 | * Returns the MIME type of the body of the request. 10 | * @returns The content type, returns null if the content type is not known. 11 | * @example var contentType = g_request.getContentType(); 12 | */ 13 | getContentType() {} 14 | /** 15 | * Returns the header value. 16 | * @param {String} name The name of the header to be retrieved. 17 | * @returns The header. 18 | * @example var headerValue = g_request.getHeader("host"); 19 | */ 20 | getHeader(name) {} 21 | /** 22 | * Returns a comma-separated list of header names. 23 | * @returns A comma-separated list of header names. 24 | * @example var headerList = g_request.getHeaderNames(); 25 | */ 26 | getHeaderNames() {} 27 | /** 28 | * Returns the header values. 29 | * @param {String} name Names of the headers to be retrieved. 30 | * @returns The header values. 31 | * @example var headerValue = g_request.getHeaders("host"); 32 | */ 33 | getHeaders(name) {} 34 | /** 35 | * Returns the value of the parameter contained in the request URL. 36 | * @param {String} name The name of the parameter to be retrieved. This can be the parameter endpoint 37 | * from the processor form. 38 | * @returns The parameter value. Returns null if the parameter is not found. 39 | * @example var name = g_request.getParameter("x_snc_custom_x_snc_name"); 40 | */ 41 | getParameter(name) {} 42 | /** 43 | * Returns a list of the parameter names found in the request URL. 44 | * @returns A comma-separated list of parameter names. 45 | * @example var paramList = g_request.getParameterNames(); 46 | */ 47 | getParameterNames() {} 48 | /** 49 | * Returns the query string from the request. 50 | * @returns The query string. 51 | * @example var daString = g_request.getQueryString(); 52 | * g_processor.writeOutput("The query string is: " + daString); 53 | */ 54 | getQueryString() {} 55 | } -------------------------------------------------------------------------------- /ES6/Transformer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Manipulate time-series data to prepare the data for evaluation and 3 | * analysis. 4 | * @class Transformer 5 | * @typedef {Object} Transformer 6 | */ 7 | class Transformer { 8 | /** 9 | * Create a Transformer object. 10 | * @param {GlideRecord} sourceRecords Contains the records for which metrics are to be evaluated. Can be one record 11 | * or many. 12 | */ 13 | constructor(sourceRecords) {} 14 | /** 15 | * Run the transform. 16 | * @param {GlideDateTime} start The beginning of the period to be evaluated. 17 | * @param {GlideDateTime} end The end of the period to be evaluated. 18 | * @returns The transformed data. 19 | * @example var minutesAgoStart = 60; 20 | * var end = new GlideDateTime(); 21 | * var start = new GlideDateTime(end); 22 | * start.addSeconds(-1 * 60 * minutesAgoStart); 23 | * // query subject records 24 | * var grDrone = new GlideRecord('mb_demo_drone'); 25 | * grDrone.query(); 26 | * // building transform; get the average transforms of a metric, grouping by model 27 | * var transformer = new sn_clotho.Transformer(grDrone); 28 | * transformer.groupBy("fleet").metric("mb_demo_mt_altitude").avg().label('avg - %g:fleet:'); 29 | * // execute and return result for visualization 30 | * var tfrmResult = transformer.execute(start, end); 31 | */ 32 | execute(start, end) {} 33 | /** 34 | * Specify a field to be used to group the data. 35 | * @param {String} field A field in the table to be used to group the transform results. 36 | * @returns A TransformPart object that can be used to specify the transform 37 | * characteristics. 38 | * @example var transformer = new sn_clotho.Transformer(grDrone); 39 | * var trnsfrm = transformer.groupBy("fleet"); 40 | */ 41 | groupBy(field) {} 42 | /** 43 | * Specify the metric field to be used in the transform. 44 | * @param {String} metricName Name of the metric field. 45 | * @returns A TransformPart object that can be used to specify the transform 46 | * characteristics. 47 | * @example var transformer = new sn_clotho.Transformer(grDrone); 48 | * var trnsfrm = transformer.metric("mb_demo_mt_altitude"); 49 | */ 50 | metric(metricName) {} 51 | } -------------------------------------------------------------------------------- /ES6/RenderProperties.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The RenderProperties API provides methods about the current page and is available in 3 | * Jelly scripts and in UI-action conditions and scripts. 4 | * @class RenderProperties 5 | * @typedef {Object} RenderProperties 6 | */ 7 | class RenderProperties { 8 | constructor() {} 9 | /** 10 | * Returns the encoded query from the URL sent to the page. 11 | * @returns Returns the encoded query from the URL sent to the form. 12 | */ 13 | getEncodedQuery() {} 14 | /** 15 | * Returns the list control object for the page. 16 | * @returns The list control object for the page. 17 | */ 18 | getListControl() {} 19 | /** 20 | * Returns the value of the specified URL parameter. 21 | * @param {String} parameterName Name of the parameter passed on the URL. 22 | * @returns The parameter's value. 23 | */ 24 | getParameterValue(parameterName) {} 25 | /** 26 | * Returns the URL where the request originated. 27 | * @returns The URL of the page where the request originated. 28 | */ 29 | getReferringURL() {} 30 | /** 31 | * Returns the name of the view in use. 32 | * @returns The name of the view being used. 33 | */ 34 | getViewName() {} 35 | /** 36 | * Returns the window's properties. 37 | * @returns The window's properties 38 | */ 39 | getWindowProperties() {} 40 | /** 41 | * Returns true if the page is part of Studio. 42 | * @returns Returns true if the page is part of Studio. 43 | */ 44 | isInDevStudio() {} 45 | /** 46 | * Returns true if this is an interactive session. An interactive session is when a user 47 | * has logged in as opposed to a REST request. 48 | * @returns True if this is an interactive session. 49 | */ 50 | isInteractive() {} 51 | /** 52 | * Returns true when the sysparm_collection_related_file URL parameter is 53 | * set. 54 | * @returns Returns true when the sysparm_collection_related_file URL 55 | * parameter is set. 56 | */ 57 | isManyToMany() {} 58 | /** 59 | * Returns true when the sys_is_related_list URL-parameter is true. 60 | * Returns false if the parameter is not present. 61 | * @returns True if the URL parameter sys_is_related_list is true. 62 | */ 63 | isRelatedList() {} 64 | } -------------------------------------------------------------------------------- /ES6/GlideModalFormV3.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Displays a form in a GlideModal. 3 | * @class GlideModalFormV3 4 | * @typedef {Object} GlideModalFormV3 5 | */ 6 | class GlideModalFormV3 { 7 | /** 8 | * Creates an instance of the GlideModalForm class. 9 | * @param {String} title The form title. 10 | * @param {String} tableName The table being shown. 11 | * @param {Function} onCompletionCallback The function to call after the form has been submitted and processed on the 12 | * server. The callback function has the form callbackFunction(String 13 | * action_verb, String sys_id, String table, String displayValue) where 14 | * action_verb is the name of the UI action executed. Examples are sysverb_insert 15 | * (Submit button), sysverb_cancel, sysverb_save (Save button). 16 | * sys_id is the sys_id of the affected record. 17 | * table is the name of the table containing the record. 18 | * displayValue 19 | * 20 | */ 21 | constructor(title, tableName, onCompletionCallback) {} 22 | /** 23 | * Sets the specified parameter to the specified value. 24 | * @param {String} name The parameter name. 25 | * @param {String} value The parameter value. 26 | * @returns Method does not return a value 27 | */ 28 | addParm(name, value) {} 29 | /** 30 | * Shows the form. 31 | * @returns Method does not return a value 32 | */ 33 | render() {} 34 | /** 35 | * Sets the function to be called when the form has been successfully submitted and 36 | * processed by the server. 37 | * @param {Function} callbackFunction The callback function to be called when the form has been successfully 38 | * processed. 39 | * @returns Method does not return a value 40 | */ 41 | setCompletionCallback(callbackFunction) {} 42 | /** 43 | * Sets the function to be called after the form has been loaded. 44 | * @param {Function} callbackFunction The function to be called after the form has been loaded. The callback function 45 | * has the form callBackFunction(GlideModalForm obj) 46 | * @returns Method does not return a value 47 | */ 48 | setOnloadCallback(callbackFunction) {} 49 | /** 50 | * Sets the object's sys_id preference. 51 | * @param {String} sys_id The id preference. One of the query parameters passed to the form. 52 | * @returns Method does not return a value 53 | */ 54 | setSysID(sys_id) {} 55 | } -------------------------------------------------------------------------------- /ES5/TableExtension.js: -------------------------------------------------------------------------------- 1 | var TableExtension = Class.create({ 2 | REF_ELEMENT_PREFIX: 'ref_', 3 | initialize: function(elementName, elementLabel) { 4 | this.name = elementName; 5 | this.label = elementLabel; 6 | this.table = null; 7 | this.fields = null; 8 | }, 9 | getName: function() { 10 | return this.name; 11 | }, 12 | getExtName: function() { 13 | return this.REF_ELEMENT_PREFIX + this.getName(); 14 | }, 15 | getLabel: function() { 16 | return this.label; 17 | }, 18 | setTable: function(t) { 19 | this.table = t; 20 | }, 21 | addOption: function(select, namePrefix, labelPrefix) { 22 | var t = this.getName(); 23 | var ext = this.getExtName(); 24 | if (namePrefix && namePrefix != '') { 25 | var idx = namePrefix.lastIndexOf("."); 26 | var s = namePrefix.substring(idx + 1); 27 | var previousIsExtension = true; 28 | if (s.indexOf(this.REF_ELEMENT_PREFIX) == 0) 29 | ext = namePrefix.substring(0,idx + 1) + ext; 30 | else { 31 | ext = namePrefix + "." + ext; 32 | previousIsExtension = false; 33 | } 34 | } 35 | var label = this.getLabel(); 36 | var reflabel = label; 37 | if (labelPrefix && labelPrefix != '') 38 | if (previousIsExtension) 39 | reflabel = labelPrefix.substring(0,labelPrefix.lastIndexOf(".")) + "." + reflabel; 40 | else 41 | reflabel = labelPrefix + "." + reflabel; 42 | tlabel = label + " (+)"; 43 | appendSelectOption(select, ext, document.createTextNode(tlabel)); 44 | var opt = select.options[select.options.length-1]; 45 | if (labelPrefix != '') 46 | opt.innerHTML = "   "+tlabel; 47 | else 48 | opt.innerHTML = tlabel; 49 | opt.cl = reflabel; 50 | opt.cv = ext; 51 | opt.tl = reflabel; 52 | opt.style.color = 'darkred'; 53 | opt.style.cursor = 'pointer'; 54 | opt.title = "Show extended fields from " + label + " table"; 55 | opt.doNotDelete = 'true'; 56 | opt.doNotMove = 'true' 57 | opt.reference = t; 58 | opt.bt = this.table.getName(); 59 | opt.btl = this.table.getLabel(); 60 | opt.headerAttr = 'true'; 61 | opt.tl = reflabel; 62 | }, 63 | type : function() { 64 | return "TableExtension"; 65 | } 66 | }); -------------------------------------------------------------------------------- /ES6/GlideOAuthClient.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use these methods for requesting and revoking OAuth refresh and access tokens. 3 | * @class GlideOAuthClient 4 | * @typedef {Object} GlideOAuthClient 5 | */ 6 | class GlideOAuthClient { 7 | constructor() {} 8 | /** 9 | * Retrieves the token for the client. You can use the token to check the expiration date 10 | * and perform a token renewal. 11 | * @param {String} OAuthEntityName The OAuth entity. 12 | * @param {String} requestor The request. 13 | * @returns The token for the client. 14 | * @example token = oAuthClient.getToken(testAppProvider, someone@someemail.com); 15 | */ 16 | getToken(OAuthEntityName, requestor) {} 17 | /** 18 | * Retrieves the token for the client, with the request parameters encoded in JSON 19 | * format. 20 | * @param {String} clientName The client name. 21 | * @param {String} jsonString The JSON string for the client. 22 | * @returns The token for the client. 23 | * @example 24 | * var oAuthClient = new GlideOAuthClient(); 25 | * var params ={grant_type:"password", username:"itil", password:'itil'}; 26 | * var json =new JSON(); 27 | * var text = json.encode(params); 28 | * var tokenResponse = oAuthClient.requestToken('TestClient', text); 29 | * var token = tokenResponse.getToken(); 30 | * gs.log("AccessToken:"+ token.getAccessToken()); 31 | * gs.log("AccessTokenExpiresIn:"+ token.getExpiresIn()); 32 | * gs.log(" RefreshToken:"+ token.getRefreshToken()); 33 | * 34 | */ 35 | requestToken(clientName, jsonString) {} 36 | /** 37 | * Retrieves the token for the client, with the client name and the request set into a 38 | * GlideOAuthClientResponse object. 39 | * @param {String} clientName The client name. 40 | * @param {GlideOAuthClientRequest} request The request. 41 | * @returns The token for the client. 42 | */ 43 | requestTokenByRequest(clientName, request) {} 44 | /** 45 | * Revokes the access or refresh token for the client, with the request and optional 46 | * header parameters set into a GlideOAuthClientRequest object. 47 | * @param {String} clientName The client name. 48 | * @param {String} accessToken The access token. 49 | * @param {String} refreshToken The refresh token. 50 | * @param {GlideOAuthClientRequest} request The request. 51 | * @returns The token for the client. 52 | */ 53 | revokeToken(clientName, accessToken, refreshToken, request) {} 54 | } -------------------------------------------------------------------------------- /ES6/CertificateEncryption.js: -------------------------------------------------------------------------------- 1 | /** 2 | * APIs available for encrypting certificates in scoped applications. 3 | * @class CertificateEncryption 4 | * @typedef {Object} CertificateEncryption 5 | */ 6 | class CertificateEncryption { 7 | /** 8 | * Instantiates a CertificateEncryption object in a scoped application. 9 | */ 10 | constructor() {} 11 | /** 12 | * Generates the Message Authentication Code (MAC), which is used to authenticate a 13 | * message. 14 | * @param {String} key Key used to sign the message. 15 | * @param {String} algorithm Algorithm used to generate the MAC: HmacSHA256, HmacSHA1, HmacMD5, and so 16 | * on. 17 | * @param {String} data Data to be processed. 18 | * @returns MAC in base64 format. 19 | * @example var mac = new CertificateEncryption; 20 | * mac.generateMac("sample_key", "HmacSHA256", "sample_data"); 21 | */ 22 | generateMac(key, algorithm, data) {} 23 | /** 24 | * Generates a hash (SHA-1, SHA-256, and so on) for the certificate from Trust Store 25 | * Cert. 26 | * @param {String} certificateID sys_id of the certificate record in the X.509 Certificate [sys_certificate] 27 | * table. 28 | * @param {String} algorithm SHA-1, SHA-256, and so on 29 | * @returns Thumbprint in base64 format. 30 | */ 31 | getThumbPrint(certificateID, algorithm) {} 32 | /** 33 | * Generates a hash (SHA-1, SHA-256, and so on) for the certificate from the keystore 34 | * entry. 35 | * @param {String} certificateID sys_id of the certificate record in the X.509 Certificate [sys_certificate] 36 | * table. 37 | * @param {String} alias Alias name for the certificate. 38 | * @param {String} algorithm SHA-1, SHA-256, and so on. 39 | * @returns Thumbprint in base64 format. 40 | */ 41 | getThumbPrintFromKeystore(certificateID, alias, algorithm) {} 42 | /** 43 | * Signs the data using the private key and the given algorithm. 44 | * @param {String} certificateID sys_id of the certificate record in the X.509 Certificate [sys_certificate] 45 | * table. 46 | * @param {String} alias Private key name. 47 | * @param {String} aliaspassword Password for the private key. 48 | * @param {String} datatosign Data to sign. 49 | * @param {String} algorithm SHA-1, SHA-256, and so on. 50 | * @returns Signed data in base64 format. 51 | * @example var ce = new CertificateEncryption; 52 | * ce.sign("recordID", "alias", "password", "SHA-1", "sign this data"); 53 | */ 54 | sign(certificateID, alias, aliaspassword, datatosign, algorithm) {} 55 | } -------------------------------------------------------------------------------- /ES6/GlideQueryCondition.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The scoped GlideQueryCondition API provides additional AND or OR conditions that can be 3 | * added to the current condition, allowing you to build complex queries. 4 | * @class GlideQueryCondition 5 | * @typedef {Object} GlideQueryCondition 6 | */ 7 | class GlideQueryCondition { 8 | constructor() {} 9 | /** 10 | * Adds an AND condition to the current condition. 11 | * @param {String} name The name of a field. 12 | * @param {String} oper (Optional) The operator for the query. If you do not specify an operator, the 13 | * condition uses an equals operator. 14 | * @param {Object} value The value to query on. 15 | * @returns A reference to a GlideQueryConditon that was added to the 16 | * GlideRecord. 17 | * @example var gr = new GlideRecord('incident'); 18 | * var qc = gr.addQuery('category', 'Hardware'); 19 | * qc.addCondition('category', 'Network'); 20 | * gr.addQuery('number','INC0000003'); 21 | * gr.next(); 22 | * gr.number; 23 | * gs.info(gr.getEncodedQuery()); 24 | */ 25 | addCondition(name, oper, value) {} 26 | /** 27 | * Appends a 2-or-3 parameter OR condition to an existing GlideQueryCondition. 28 | * @param {String} name Field name 29 | * @param {String} oper (Optional) Query operator. The available values are dependent on the data 30 | * type of the value parameter.Numbers: 31 | * = 32 | * != 33 | * > 34 | * >= 35 | * < 36 | * <= 37 | * Strings (must be in upper case): 38 | * = 39 | * != 40 | * IN 41 | * STARTSWITH 42 | * ENDSWITH 43 | * CONTAINS 44 | * DOESNOTCONTAIN 45 | * 46 | * @param {Object} value Value on which to query (not case-sensitive).Note: All passed in arrays must 47 | * contain a minimum of two elements. Single element arrays are not 48 | * supported. 49 | * @returns A reference to a GlideQueryConditon that was added to the 50 | * GlideRecord. 51 | * @example var gr = new GlideRecord('incident'); 52 | * var qc = gr.addQuery('category', 'Hardware'); 53 | * qc.addOrCondition('category', 'Network'); 54 | * gr.addQuery('number','INC0000003'); 55 | * gr.next(); 56 | * gr.number; 57 | * gs.info(gr.getEncodedQuery()); 58 | * 59 | * @example var myObj = new GlideRecord('incident'); 60 | * var q1 = myObj.addQuery('state', '<', 3); 61 | * q1.addOrCondition('state', '>', 5); 62 | * var q2 = myObj.addQuery('priority', 1); 63 | * q2.addOrCondition('priority', 5); 64 | * myObj.query(); 65 | */ 66 | addOrCondition(name, oper, value) {} 67 | } -------------------------------------------------------------------------------- /ES6/GlideExcelParser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * You can parse .xlsx formatted Excel files. 3 | * @class GlideExcelParser 4 | * @typedef {Object} GlideExcelParser 5 | */ 6 | class GlideExcelParser { 7 | /** 8 | * Creates an instance of GlideExcelParser. 9 | */ 10 | constructor() {} 11 | /** 12 | * Close the connection to the input stream and release the document. 13 | * @returns Method does not return a value 14 | */ 15 | close() {} 16 | /** 17 | * Returns a list of column headers from the parsed document. 18 | * @returns An array of strings of column headers from the parsed document. 19 | */ 20 | getColumnHeaders() {} 21 | /** 22 | * Returns the error message when the parse() method fails. 23 | * @returns The error message. 24 | */ 25 | getErrorMessage() {} 26 | /** 27 | * Get the current row values and headers. 28 | * @returns The row headers are property names and the row values are property 29 | * values. 30 | */ 31 | getRow() {} 32 | /** 33 | * Moves to the next row. 34 | * @returns Returns true if there is a next row, otherwise, returns false. 35 | */ 36 | next() {} 37 | /** 38 | * Parse an XLSX formatted Excel document. 39 | * @param {GlideScriptableInputStream} inputStream The Excel document to be parsed. 40 | * @returns Returns true if the parse was successful, otherwise, returns false. 41 | * @example var parser = new sn_impex.GlideExcelParser(); 42 | * parser.parse(request.body.dataStream); 43 | */ 44 | parse(inputStream) {} 45 | /** 46 | * Set the number of the header row to be retrieved. 47 | * @param {Number} headerRowNumber The header row to be retrieved. 48 | * @returns Method does not return a value 49 | */ 50 | setHeaderRowNumber(headerRowNumber) {} 51 | /** 52 | * Return an empty value instead of null when an Excel cell is not present. 53 | * @param {Boolean} empty When true, cells that are not present return an empty value. When false, cells 54 | * that are not present return null. 55 | * @returns Method does not return a value 56 | */ 57 | setNullToEmpty(empty) {} 58 | /** 59 | * Set the name of the sheet to be retrieved. 60 | * @param {String} sheetName The name of the sheet to be retrieved. 61 | * @returns Method does not return a value 62 | */ 63 | setSheetName(sheetName) {} 64 | /** 65 | * Set the number of the Excel sheet to be retrieved. 66 | * @param {Number} sheetNumber The Excel sheet number to retrieve. 67 | * @returns Method does not return a value 68 | */ 69 | setSheetNumber(sheetNumber) {} 70 | } -------------------------------------------------------------------------------- /ES6/Conversation.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Conversation API enables you to create or modify Connect conversations. 3 | * @class Conversation 4 | * @typedef {Object} Conversation 5 | */ 6 | class Conversation { 7 | constructor() {} 8 | /** 9 | * Adds 10 | * a user to a conversation. 11 | * @param {String} sysID The sys_ID of the user you want to add to a conversation. 12 | * @returns Method does not return a value 13 | * @example var conversation = sn_connect.Conversation.get("7caf49111309030034bb58a12244b06c"); 14 | * conversation.addSubscriber("a8f98bb0eb32010045e1a5115206fe3a"); 15 | */ 16 | addSubscriber(sysID) {} 17 | /** 18 | * Creates a Connect 19 | * conversation. 20 | * @param {String} name Create a conversation with a specific name. 21 | * @param {String} type Include a specific conversation type. The type is determined by the type choice 22 | * list. The base system includes the following type options: 23 | * connect 24 | * support 25 | * group 26 | * peer 27 | * qanda 28 | * team 29 | * 30 | * @returns Scriptable Conversation 31 | * @example var conversation = sn_connect.Conversation.create({ 32 | * name: "Hello world", 33 | * type: "connect" 34 | * }); 35 | */ 36 | create(name, type) {} 37 | /** 38 | * Returns an existing Connect conversation by sys_id. 39 | * @param {String} sysID The sys_id of the conversation record. 40 | * @returns Conversation object 41 | * @example var conversation = sn_connect.Conversation.get("27b9844c1385030034bb58a12244b037"); 42 | */ 43 | get(sysID) {} 44 | /** 45 | * Removes 46 | * a user from a conversation. 47 | * @param {String} SysID The sys_id of the user you want to remove from a conversation. 48 | * @returns Method does not return a value 49 | * @example var conversation = sn_connect.Conversation.get("7caf49111309030034bb58a12244b06c"); 50 | * conversation.removeSubscriber("a8f98bb0eb32010045e1a5115206fe3a"); 51 | */ 52 | removeSubscriber(SysID) {} 53 | /** 54 | * Sends a message to a conversation. 55 | * @param {String} Body The main text of the message. 56 | * @param {String} Field The field you want the message to appear as. Only use this option if adding a 57 | * message to a record conversation. Choose from work_notes, comments, or system. Using 58 | * system as the field treats the message as a system message. 59 | * @returns Method does not return a value 60 | * @example var conversation = sn_connect.Conversation.get("2064fa3919010300964f5270e9840fbb"); 61 | * conversation.sendMessage(body: "Hello world", field: "work_notes"); 62 | */ 63 | sendMessage(Body, Field) {} 64 | } -------------------------------------------------------------------------------- /ES6/GlideMenu.js: -------------------------------------------------------------------------------- 1 | /** 2 | * GlideMenu methods are used in UI Context Menus, in the onShow scripts to customize UI 3 | * Context Menu items. 4 | * @class GlideMenu 5 | * @typedef {Object} GlideMenu 6 | */ 7 | class GlideMenu { 8 | constructor() {} 9 | /** 10 | * Clears the image for an item. 11 | * @param {GlideMenuItem} item Specifies the item to have its image removed from display. 12 | * @returns Method does not return a value 13 | * @example g_menu.clearImage(g_item); 14 | */ 15 | clearImage(item) {} 16 | /** 17 | * Clears any selection images from items in the menu. 18 | * @returns Method does not return a value 19 | */ 20 | clearSelected() {} 21 | /** 22 | * Returns a menu item by item ID. 23 | * @param {String} itemID Specifies the item to be returned. 24 | * @returns The menu item 25 | */ 26 | getItem(itemID) {} 27 | /** 28 | * Disables a menu item so that it cannot be selected. The disabled menu item is displayed 29 | * in a lighter color (grayed out) to indicate it is disabled. 30 | * @param {GlideMenuItem} item The item to be disabled. 31 | * @returns Method does not return a value 32 | * @example g_menu.setDisabled(g_item); 33 | */ 34 | setDisabled(item) {} 35 | /** 36 | * Enables the specified menu item. 37 | * @param {GlideMenuItem} item The item to be enabled. 38 | * @returns Method does not return a value 39 | * @example g_menu.setEnabled(g_item); 40 | */ 41 | setEnabled(item) {} 42 | /** 43 | * Hides the specified menu item. 44 | * @param {GlideMenuItem} item The item to be hidden. 45 | * @returns Method does not return a value 46 | * @example g_menu.setHidden(g_item); 47 | */ 48 | setHidden(item) {} 49 | /** 50 | * Sets an image for an item. 51 | * @param {GlideMenuItem} item the item to have the image displayed. 52 | * @param {String} imgSrc the image to attach to the menu item. 53 | * @returns Method does not return a value 54 | * @example g_menu.setImage(g_item, 'images/checked.gifx'); 55 | */ 56 | setImage(item, imgSrc) {} 57 | /** 58 | * Sets the display label for a menu item. The label may contain HTML. 59 | * @param {GlideMenuItem} item the item to be labeled. 60 | * @param {String} label the label to be displayed. The string may contain HTML. 61 | * @returns Method does not return a value 62 | * @example g_menu.setLabel(g_item, "This is a new label"); 63 | */ 64 | setLabel(item, label) {} 65 | /** 66 | * Displays the specified item. 67 | * @param {GlideMenuItem} item The item to be displayed. 68 | * @returns Method does not return a value 69 | * @example g_menu.setVisible(g_item); 70 | */ 71 | setVisible(item) {} 72 | } -------------------------------------------------------------------------------- /ES6/GlideEmailOutbound.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The scoped GlideEmailOutbound class implements the email object for scoped applications. 3 | * You can use the GlideEmailOutbound methods with the email global object available in mail scripts. 4 | * The email object behaves identically for global and scoped applications. 5 | * @class GlideEmailOutbound 6 | * @typedef {Object} GlideEmailOutbound 7 | */ 8 | class GlideEmailOutbound { 9 | /** 10 | * Instantiates a scoped GlideEmailOutbound object. 11 | */ 12 | constructor() {} 13 | /** 14 | * Adds the address to either the cc or bcc list. 15 | * @param {String} type Either cc or bcc, determines the list to which the address is added. 16 | * @param {String} address The recipient's email address. 17 | * @returns Method does not return a value 18 | * @example email.addAddress('cc', 'joe.employee@something.com'); 19 | */ 20 | addAddress(type, address) {} 21 | /** 22 | * Adds the recipient to either the cc or bcc list, but uses the display name instead of 23 | * the address when showing the recipient. 24 | * @param {String} type Either cc or bcc, determines the list to which the address is added. 25 | * @param {String} address The recipient's email address. 26 | * @param {String} displayName The name to be shown instead of the email address. 27 | * @returns Method does not return a value 28 | * @example email.addAddress('bcc', 'joe.employee@something.com', 'dudley rocks'); 29 | */ 30 | addAddress(type, address, displayName) {} 31 | /** 32 | * Returns the email's subject line. 33 | * @returns The email's subject line. 34 | * @example var subject = email.getSubject(); 35 | */ 36 | getSubject() {} 37 | /** 38 | * Sets the body of the email. 39 | * @param {String} bodyText The body of the email. 40 | * @returns Method does not return a value 41 | * @example email.setBody('Dear Sir, ...'); 42 | */ 43 | setBody(bodyText) {} 44 | /** 45 | * Sets the sender's address. 46 | * @param {String} address The sender's email address. 47 | * @returns Method does not return a value 48 | * @example email.setFrom('joe.employee@something.com'); 49 | */ 50 | setFrom(address) {} 51 | /** 52 | * Sets the reply to address. 53 | * @param {String} address The reply to email address. 54 | * @returns Method does not return a value 55 | * @example email.setReplyTo('joe.employee@something.com'); 56 | */ 57 | setReplyTo(address) {} 58 | /** 59 | * Sets the email's subject line. 60 | * @param {String} subject Text for the subject line. 61 | * @returns Method does not return a value 62 | * @example email.setSubject('Important Issues to discuss'); 63 | */ 64 | setSubject(subject) {} 65 | } -------------------------------------------------------------------------------- /ES5/Select.js: -------------------------------------------------------------------------------- 1 | //defer classes/Select.js 2 | /** 3 | * Manage a