Skip to content

Instantly share code, notes, and snippets.

View cmcdevitt's full-sized avatar
🏠
Working from home

Chris McDevitt cmcdevitt

🏠
Working from home
View GitHub Profile
@cmcdevitt
cmcdevitt / ChkAndAddITILtoGroups
Last active December 25, 2015 09:29
ServiceNow -- Go through all your groups and add the ITIL role to each group.
//Set the ITIL Role on all Groups in ServiceNow (Calgary)
//Run this as a Scheduled Job
cm_SetItilRoleToGroups();
function cm_SetItilRoleToGroups(){
//**** --> Change this variable to reflect the Role you want to set on All Groups <-- ****
var roleNameForAllGroups = 'itil';
var groupCount = 0; ///How many groups
//Test Device
//work in progress 11/20/2013
//Dependencies
//-- UI Action: Test Device Table: Notification Device [cmn_notif_device], Form Button, Show update (show insert?), Cond:current.isValidRecord()
//-- Event: cmn_notif_device.test_device
//-- Notification: 'Test My Device'
//**** Development Notes *****
//Add Notification to cmn_notif_message
//-- Need: Notification Message,User,Device,Send Email,Send SMS
@cmcdevitt
cmcdevitt / addUserToGroupForNotification
Created December 4, 2013 02:13
Using a Business Rule add a user to a group when a certain notification is added to their device
//When a user addes a certain notification to thier device, add them to a group (Group paging)
//Business Rule -- ServiceNow
//Name:addUserToGroupForNotification
//Table: Notification Messages [cmn_notif_message]
//Order: 500, When: async, Priority: 500, Insert
//If "P1/P2 All Manager Notify New"(sysevent_email_action).
//-->Then, add user(sys_user) to "IT Managers" group(sys_user_group)(sys_user_grmember)
cm_addUserToGroupForNotification();
@cmcdevitt
cmcdevitt / Jelly_boot_angular
Created December 5, 2013 02:11
Sample UI Page that loads Bootstrap and 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">
<!-- Start HTML -->
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css"></link>
<h1>Hello World!</h1>
<p class="text-danger">Danger</p>
<div ng-app='' class='ng-cloak container'>
Write some text in textbox:
<input type="text" ng-model="sometext" />
@cmcdevitt
cmcdevitt / JasmineHelper
Created December 10, 2013 03:01
Jasmine Helper is a support class for the Jasmine Test Suite in ServiceNow implemented by Fruition Partners Test Runner
//Version 0.01 12/09/2013
//ServiceNow / Fruition Partners Test Runner
//Supporting Class for Jasamine Test Suites
var JasmineHelper = Class.create();
JasmineHelper.prototype = {
initialize: function() {
},
getSysID: function(itemName,tableName){
@cmcdevitt
cmcdevitt / Jelly For Incident
Created January 24, 2014 00:24
ServiceNow Jelly Check for Incident
<?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:evaluate var="jvar_gr" object="true">
var gr = new GlideRecord("incident");
gr.addQuery("state","=", "2");
gr.addQuery("category","=", "Sales and Service");
gr.query();
gr;
@cmcdevitt
cmcdevitt / gist:8676214
Created January 28, 2014 20:54
ServiceNow email script list catalog item and varables
<mail_script>
template.print("<p></p>Requested items:\n");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sysapproval);
gr.query();
while(gr.next()) {
template.print(gr.number + ": " + gr.cat_item.getDisplayValue() + ", Stage: " + gr.stage.getDisplayValue() + "\n");
var newDate = new Date( );
var unix = 1399665294;
newDate.setTime(unix*1000); // JavaScript is in milliseconds and unix is in seconds
dateString = newDate.toUTCString();
gs.log("Epoch: " + dateString);
@cmcdevitt
cmcdevitt / gist:c1ff335b3c7abcf4150d
Created May 12, 2014 14:22
ServiceNow day of the week
var gdt = new GlideDateTime();
if(gdt.getDayOfWeek() == 7){
gs.log("Today is Sunday");
gs.addInfoMessage("Hello World");
}
@cmcdevitt
cmcdevitt / gist:d77de635802bddb4d462
Created May 12, 2014 14:22
ServiceNow start of week
var sevenDays = new GlideTime();sevenDays.setValue("168:00:00");var today = new GlideDateTime(gs.nowDateTime());var dtUtil = new DateTimeUtils();var firstDay = gs.getProperty("com.snc.time_card.start_day", 7);var start = dtUtil.getWeekStart(today, firstDay);start.subtract(sevenDays);start.getDisplayValue();