Skip to content

Instantly share code, notes, and snippets.

View paulsena's full-sized avatar

Paul Senatillaka paulsena

View GitHub Profile
@paulsena
paulsena / keybase.md
Created September 12, 2019 16:33
Keybase.io Proof

Keybase proof

I hereby claim:

  • I am paulsena on github.
  • I am paulsena (https://keybase.io/paulsena) on keybase.
  • I have a public key ASBxbLvpyLzQHGLdWDEgNGo13qTE1vQclAZFhxLWCys9Igo

To claim this, I am signing this object:

@paulsena
paulsena / keybase.md
Created July 1, 2015 20:03
Keybase Proof

Keybase proof

I hereby claim:

  • I am paulsena on github.
  • I am paulsena (https://keybase.io/paulsena) on keybase.
  • I have a public key whose fingerprint is 7B33 FFD1 DD7C 850E B9F4 88D4 E2ED 4587 2985 7060

To claim this, I am signing this object:

@paulsena
paulsena / gist:700ce1d75648ac25b177
Created April 6, 2015 05:12
Restify Node.js WS that executes a singleton cmd shell process. Was used as a POC for a WS controllable Raspberry Pi LED Text Ticker.
var restify = require('restify');
var sys = require('sys')
var exec = require('child_process').exec;
var child;
var USERNAME = 'sal';
var PASSWORD = '16BrooksSt';
var CMD = "emacs";
//**** REST CODE ******
function respond(req, res, next) {
@paulsena
paulsena / getUserIncidents.js
Created April 15, 2014 16:28
ServiceNow Scripted WS that returns the incidents created for a certain user. Returns Incident Number, State Value, and State Display Name for each incident. Accepts a few parameters for filtering such as callerId, active, orderBy, orderByDesc, firstRow, lastRow, limit. Uses a JSON object to build up the dynamic SOAP response data then passes it…
response.response = getUserIncidents();
function getUserIncidents() {
var recordSet= [];
var callerId = request.caller_id;
var active = request.active;
var orderBy = request.order_by;
var orderByDesc = request.order_by_desc;
var firstRow = request.first_row ? request.first_row : 1;
@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 / 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 / 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 / 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
@paulsena
paulsena / AttachmentImportProcessor.js
Last active February 18, 2021 19:35
Service Now Email Attachment Processor.Allows ServiceNow to accept attachments via email and process them through a data source/import set/ transform map.
/*
* Script include to process multiple attachments in an email through OOB Data Source process.
* Attaches to existing data source, dynamically creates a schedule import entry and runs.
* Processes attachments synchronously to prevent issues with multiple attachments
*
* Source: Fruition Partners
* Author: Chris.Nanda@fruitionpartners.com
* Author: Paul.Senatillaka@fruitionpartners.com
*/
@paulsena
paulsena / AjaxDateDiffCalcBusDays.js
Created April 8, 2014 13:06
ServiceNow Script Include, called by Client Script. This script calculates the difference between the current date and a date passed in as a parameter using 8X5 Business Workday Schedule.
/*
* Called by Client Script. This script calculates the difference between the current date and a date passed in as a parameter
* using 8X5 Business Workday Schedule.
*/
var AjaxDateDiffCalcBusDays = Class.create();
AjaxDateDiffCalcBusDays.prototype = Object.extendsObject(AbstractAjaxProcessor, {
dateDiffNow: function()
{
// Get Catalog Item
var cat = new GlideRecord('sc_cat_item');