Skip to content

Instantly share code, notes, and snippets.

@ChecksumFailed
ChecksumFailed / ReadeMe.md
Last active June 23, 2023 22:31
Script Include to make dealing with ServiceNow Variable Easier

Helper script include for dealing with variables in servicenow

@ChecksumFailed
ChecksumFailed / emailScriptHelper.js
Last active April 11, 2022 17:48
Script functions to help with email scripts
var emailScriptHelper = Class.create();
emailScriptHelper.prototype = {
initialize: function() {},
varsToHTMLTable: function(variables) {
if (variables == 'undefined') {
return;
}
var helperOptions = {'useLable': true,'useDisplayValue': true};
@ChecksumFailed
ChecksumFailed / UpdateRecordsFromAudit.js
Last active June 23, 2023 20:44
Update Records with values from audit table
function validateQuery(grToCheck) {
return grToCheck.isEncodedQueryValid(grToCheck.getEncodedQuery());
}
function isNullOrEmpty(val) {
return val == null || val == '' || val == undefined;
}
function validateQuery(grToCheck) {
return grToCheck.isEncodedQueryValid(grToCheck.getEncodedQuery());
}
function isNullOrEmpty(val) {
return val == null || val == '' || val == undefined;
}
function validateArgs() {
@ChecksumFailed
ChecksumFailed / ServiceNow_ExcelToObject.js
Last active June 12, 2023 18:07
ServiceNow: Convert Excel attachment to an object
function excelToObject(attID) {
if (!attID || !isValidSysId(attID)) {
throw new Error("Valid attachment id required");
}
var excelObj = [];
var attachment = new GlideSysAttachment();
var attachmentStream = attachment.getContentStream(attID);
@ChecksumFailed
ChecksumFailed / SecretServer.js
Last active October 29, 2021 12:31
Script include used as part of secret server discovery integration. Inspired by https://joscor.com/blog/servicenow-thycotic-secret-server/
var SecretServer = Class.create();
SecretServer.prototype = {
initialize: function() {
this.BASE_URL = 'https://mySecretServer/SecretServer'; //temp change due to load balanced URL being down
this.AUTH_PROFILE = 'SYSID'; //sys_id of basic auth profile
this.TOKEN_CRED = this._getCredential(this.AUTH_PROFILE); //Glide Record of auth Profile
this.ACCESS_TOKEN = ''; //Holder for Access Token
var recordToHTML = (function() {
//class variables
var exclusions = {
"sections": [],
"fields": []
};
/********************************
var getCartItem = function (sys_id) {
var gr = new GlideRecord("sc_cart_item");
gr.get(sys_id);
return gr;
};
var addAttToCartItems = function (items,cat_item) {
var attachment = new GlideSysAttachment();
//set up inputs
(function () {
function newGrObject(tbl, obj) {
var grRec = new GlideRecord(tbl);
new GlideRecordUtil().mergeToGR(obj, grRec);
grRec.insert();
}
var oldUiPolicy = 'f6e44e7bdbc005101ad90cd7f4961916';
var newUiPolicy = '05610f08db50c5101ad90cd7f4961937';
var tbl = 'catalog_ui_policy_action';
@ChecksumFailed
ChecksumFailed / dotWalkObject.js
Last active March 2, 2023 15:14
Dot walk object until last property reached
/**
* Dot walk object until last property reached
* @param {Object} obj obj
* @param {Array} props array of object properties
* @returns the last object value
*/
function recurseObjChildren(obj, props) {
props = Array.isArray(props) ? props : props.split('.');
var item = props.shift();
var arrLen = props.length;