Skip to content

Instantly share code, notes, and snippets.

View nancystodd's full-sized avatar

Nancy S Todd nancystodd

View GitHub Profile
@nancystodd
nancystodd / Client Script-Open GlideOverlay Window to Submit or Update Another Record.js ServiceNow Client Script GlideOverlay: Open GlideOverlay Window to Submit or Update Another Record.js
// opens a new u_error_reporting record from an sc_task record
function openOverlay(overlayID, overlayTitle, iframeURI, height, width) {
// Instantiate the GlideOverlay
// Note: GlideOverlay extends GlideBox, which contains the close() method
var overlayWindow = new GlideOverlay({
id: overlayID,
title: overlayTitle,
iframe: iframeURI,
allowOverflowX: true,
closeOnEscape: true,
@nancystodd
nancystodd / globalJS
Last active May 1, 2018 00:03 — forked from cmcdevitt/globalJS
Explore Global JavaScript Object in ServiceNow in a UI Page - Modified to show property values
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<script>
document.writeln("Prototype.Version: " + Prototype.Version + "<br />");
document.writeln("Lets look at Global in ServiceNow: <br />");
myGlobal = this;
@nancystodd
nancystodd / Print Info about fields in ServiceNow
Created April 26, 2018 00:46
Background Script: Print Info about fields in ServiceNow
//Print Information about Fields in ServiceNow
(function() {
var grSection = new GlideRecord('sys_ui_section');
grSection.query();
while (grSection.next()) {
var grSectionElement = new GlideRecord('sys_ui_element');
grSectionElement.addQuery('sys_ui_section',grSection.sys_id);
grSectionElement.OrderBy('position');
grSectionElement.query();
while (grSectionElement.next()) {
@nancystodd
nancystodd / README-Template.md
Created April 25, 2018 15:39 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@nancystodd
nancystodd / getXMLNodes.js
Last active June 26, 2018 21:44
Get nodes from XMLDocument - SN example
var response = s.post();
var xmldoc = new XMLDocument(response, true);
var nodelist = xmldoc.getNodes("//Action/*");
for(var i=0;i<nodelist.getLength();i++){
gs.print(nodelist.item(i).getNodeName() +' : '+nodelist.item(i).getLastChild().getNodeValue()+'\n');
@nancystodd
nancystodd / sn_search_field_for_duplicate_values.md
Created February 6, 2018 18:57 — forked from harrisitservices/sn_search_field_for_duplicate_values.md
ServiceNow - Search Field for Duplicate Values

Search Field for Duplicate Values

This script uses GlideAggregate to search a field on a table for duplicate values. It then returns the value with duplicates in an array.

var xx = new GlideAggregate('table');  
xx.addAggregate('COUNT', 'field');  
xx.addHaving('COUNT', 'field', '>', '1');  
xx.query();  
var answer = []; 
@nancystodd
nancystodd / CSDashboard.html
Created February 6, 2018 18:55 — forked from afaulkinberry/CSDashboard.html
ServiceNow UI Page using AngularJS
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:requires name="angular-min.1.3.16.jsdbx" />
<link href="3ca86ab937380a006215d68543990ef6.cssdbx" rel="stylesheet" type="text/css"></link>
<g2:evaluate var="jvar_stamp">
var gr = new GlideRecord('sys_ui_script');
gr.get("13a5ea4d37300a006215d68543990e41");
gr.getValue('sys_updated_on');
</g2:evaluate>
<g:requires name="cs-dashboard-script.jsdbx" params="cache=$[jvar_stamp]" />
@nancystodd
nancystodd / Global Script Search.js
Created February 6, 2018 18:47 — forked from thornem3/Global Script Search.js
ServiceNow code snippits
//Stick this in a background script and use to search scripts anywhere in the system.
var term = "search,terms"; //use comma to separate terms
var useAndQuery = true; //search for term 1 and term 2. If false, it will look for term 1 or term 2.
var debug = false; //set this true if you want to troubleshoot the script.
var delimiter = ","; //if you want to split terms on something other than a comma
var globalScriptSearch = {
search: null,
@nancystodd
nancystodd / servicenow_datatables.js
Created February 6, 2018 18:43 — forked from dmfranko/servicenow_datatables.js
ServiceNow and datatables
<?xml version="1.0" encoding="UTF-8"?>
<j:jelly xmlns:j="jelly:core" xmlns:g="glide" xmlns:g2="null" xmlns:j2="null" trim="false">
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js" />
<!-- Don't include bootstrap or jquery-->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/r/bs/pdfmake-0.1.18,dt-1.10.9,b-1.0.3,b-html5-1.0.3,b-print-1.0.3,r-1.0.7,sc-1.3.0/datatables.min.css" />
<script type="text/javascript" src="https://cdn.datatables.net/r/bs/pdfmake-0.1.18,dt-1.10.9,b-1.0.3,b-html5-1.0.3,b-print-1.0.3,r-1.0.7,sc-1.3.0/datatables.min.js" />
<div class="container" id="container" ng-app="myApp">
<h4>My Incidents</h4>
<table class="table display nowrap" id="incidents" ng-controller="IncidentController" cellspacing="0" width="100%">
@nancystodd
nancystodd / background.script.js
Created February 6, 2018 18:39 — forked from mozrat/background.script.js
ServiceNow PDF Generation
var UP3PDF = Class.create();
UP3PDF.prototype = Object.extendsObject(AbstractAjaxProcessor, {
_document : null,
createPDF : function(html, table, sys_id, filename) {
var pdfDoc = new GeneralPDF.Document(null, null, null, null, null, null);
this._document = new GeneralPDF(pdfDoc);
this._document.startHTMLParser();
this._document.addHTML(html);