Skip to content

Instantly share code, notes, and snippets.

@paulsena
paulsena / JournalSyncHelper - Include.js
Created April 8, 2014 13:17
Service Now Helper Script to Syncronize the Journal fields between Instances. If you can, it is recommended to just sync the text using getJournalEntry. This script will replicate all Activity log history, Audit records, and Journal table entries so it looks like it originated from the target instance.
/*Name: JournalSyncHelper
* Description: Helper class for Masco Milgard 2 way sync. Allows Journal fields (Comments, Worknotes) to be synced.
* Helper functions to package up Comments and WorkNotes to a JSON String. Also function to decode and insert
* packaged journal field back in SN.
* Author: Paul.Senatillaka@fruitionpartners.com
*
* Version: 2.0 - 10/11/13 - Rewrite from v1 to better handle large comments and numerous other fixes.
*/
gs.include("PrototypeServer");
var JournalSyncHelper = Class.create();
@paulsena
paulsena / SAML 2.0 Update 1 Modified AuthN POST.js
Created April 8, 2014 13:25
Modified version of SSO SAML 2.0 Update 1 Script Include. Adds support for HTTP POST on AuthNRequests. Out of box ServiceNow just supports HTTP Redirection when sending Auth Requests from SN to the Identity Provider. Added a new function called generateAuthnRequestForm. Call this function from the Installation Exist Script instead of generateAut…
gs.include("PrototypeServer");
var SAML2Error = Class.create();
SAML2Error.prototype = Object.extend(new Error(), {
initialize : function(message) {
this.name = "SAML2Error";
this.message = message;
}
});
@paulsena
paulsena / AppAccessRequestHelper.js
Created April 8, 2014 13:31
ServiceNow Scripted Web Service example that will create a Service Request item with variables. Has user friendly data validation. This particular example is for an Item called Sailpoint and passes 3 variables. The web service checks mandatory fields and validates data is valid. Returns user friendly error messages if it fails any of the checks.
var AppAccessRequestHelper = Class.create();
AppAccessRequestHelper.prototype = {
initialize: function() {
this.debug = gs.getProperty("intuit.custom.debug", "true");
this.error_message = String();
this.applicationId = '';
},
//WS Wrapper function to handle Request and Response Object.
//This is called from a Scripted WS.
@paulsena
paulsena / CSV Delimiter Check.py
Created April 8, 2014 13:14
Python script to check for mismatched number of Columns in a CSV file. Useful for checking files before loading into ServiceNow because SN doesn't tell you what line number had a mismatch, it just rejects the whole file.
#! /usr/bin/env python
import fileinput
import sys
headerColCnt = 0
mismatches = 0
delimiter = "|"
def process(line):
global headerColCnt