Skip to content

Instantly share code, notes, and snippets.

@jmbauguess
jmbauguess / SNBuild.xml
Last active October 11, 2018 03:36
Uses REST integrations with Jenkins and a NodeJS program to automatically extract source code from a ServiceNow instance and save it to a repository. See http://sensibleservicenow.com/2015/08/17/automatic-source-control-and-you-save-time-and-headaches
<?xml version="1.0" encoding="UTF-8"?>
<unload unload_date="2015-08-14 17:18:17">
<sys_remote_update_set action="INSERT_OR_UPDATE">
<application display_value="Global">global</application>
<application_name>Global</application_name>
<application_scope>global</application_scope>
<application_version/>
<collisions/>
<commit_date/>
<deleted/>
@jmbauguess
jmbauguess / JSONtoGlide.js
Last active May 2, 2022 19:24
Converts a GlideRecord object into JSON, or converts JSON into a GlideRecord. See http://sensibleservicenow.com/?p=49
/**
* @description Converts between JSON Objects and GlideRecords
* @namespace
* @type {Class}
*/
var JSONtoGlide = Class.create();
JSONtoGlide.prototype = {
/**
* @description Converts an object into a new GlideRecord
* @param {Object} json A json object
@jmbauguess
jmbauguess / SNDataCopy.xml
Last active May 1, 2018 00:20
Contains functionality for copying data from a child to its parent once the parent commits the update set. Useful for moving metadata that normally does not move in update sets. See http://sensibleservicenow.com/?p=49
<?xml version="1.0" encoding="UTF-8"?>
<unload unload_date="2015-08-14 22:59:24">
<sys_remote_update_set action="INSERT_OR_UPDATE">
<application display_value="Global">global</application>
<application_name>Global</application_name>
<application_scope>global</application_scope>
<application_version/>
<collisions/>
<commit_date/>
<deleted/>
@jmbauguess
jmbauguess / SLARunner.js
Last active August 4, 2016 13:08
Updates SLAs based on a period of time
/**
* @description Updates SLAs based on conditions and stages
* @namespace
* @type {Class}
*/
var SLARunner = Class.create();
SLARunner.prototype = {
/**
* @description The name of the SLA table
* @type {String}
@jmbauguess
jmbauguess / ClassGenerator.xml
Created August 19, 2015 17:16
Update Set to generate Selenium Page Objects for ServiceNow
<?xml version="1.0" encoding="UTF-8"?>
<unload unload_date="2015-08-14 18:47:45">
<sys_remote_update_set action="INSERT_OR_UPDATE">
<application display_value="Global">global</application>
<application_name>Global</application_name>
<application_scope>global</application_scope>
<application_version/>
<collisions/>
<commit_date/>
<deleted/>
@jmbauguess
jmbauguess / RequestTester.js
Created August 26, 2015 15:25
Creates Requested Items that can be approved and worked for testing purposes
/**
* @description Creates Requested Items that can be approved and worked for testing purposes
* @namespace
* @type {Class}
*/
var RequestTester = Class.create();
RequestTester.prototype = {
/**
* @description Creates a Requested Item given a name of a catalog item and variables to enter
* @param {String} name The name of a catalog item
@jmbauguess
jmbauguess / EventTester.js
Last active November 20, 2018 11:17
Allows unit testing of Events
/**
* @description Allows unit testing of Events
* @namespace
* @example
* //Create an incident, update the state, then ensure the incident.state.changed event was fired
* var incident = new GlideRecord('incident');
* if (incident.get(sys_id)) {
* incident.state = 2;
* incident.update();
* }
/**
* @description Searches for email notifications based on certain criteria
* @namespace
* @type {Class}
*/
var NotificationsTester = Class.create();
NotificationsTester.prototype = {
/**
* @description The name of the email table
* @type {String}
@jmbauguess
jmbauguess / ApprovalEventsHandler.js
Last active September 1, 2015 02:20
Refactoring the Approval Events (task) Business Rule into a script include
/**
* @description Determines what event to use when the approval state changes on a task record
* @namespace
* @type {Class}
*/
var ApprovalEventsHandler = Class.create();
ApprovalEventsHandler.prototype = {
/**
* @description Cancelled state value
* @type {String}
@jmbauguess
jmbauguess / EncodedQueryReversal.js
Created September 14, 2015 17:53
A script include to reverse the conditions of an encoded query
/**
* @description Reverses an encoded query to provide the oppposite of what it would normally provide
* @namespace
* @type {Class}
*/
var EncodedQueryReversal = Class.create();
EncodedQueryReversal.prototype = {
/**
* @description Contains objects of conditions and what to replace them with
* @type {Array}