Skip to content

Instantly share code, notes, and snippets.

View jsmayo's full-sized avatar
👨‍💻

Jesse jsmayo

👨‍💻
View GitHub Profile
/*
ORIGINAL OO CODE:
var Vehicle = function (x, y, speed) {
this.x = x;
this.y = y;
this.speed = speed;
};
Vehicle.prototype.move = function() {
this.x = this.x + this.speed * this.randomStep();
@jacebenson
jacebenson / 001_validate_date_p_today.js
Created September 22, 2017 03:57
Catalog Client Scripts
//Validate Date is after today
//GwtDate not available on service portal
function onSubmit() {
//Type appropriate comment here, and begin script below
//validate that the start date is before the today's date
var field = 'start_date';
var st = g_form.getValue(field);
var newTime = new GwtDate(st);
var tm = new GwtDate();
tm.now();
@jacebenson
jacebenson / _verify_unsubscribe.md
Last active November 26, 2018 16:38
Verify Unsubscribe

@jacebenson
jacebenson / internal_catalog.do.xml
Created September 22, 2017 03:33
UI Page to redirect to new Service Portal
<?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>
window.location.href = '/cms'
</script>
</j:jelly>
@jacebenson
jacebenson / global.choiceUtil.si.js
Created September 22, 2017 03:31
Show Hints for choice lists
//script include global.choiceUtil
//client callable true
var choiceUtil = Class.create();
choiceUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getHint: function() {
try {
var returnObj = {};
var hint = new GlideRecord('sys_choice');
hint.addQuery('name', this.getParameter('sysparm_table'));
hint.addQuery('field', this.getParameter('sysparm_field'));
@jacebenson
jacebenson / push_comments_to_ritm_from_sc_task.br.js
Created September 22, 2017 03:28
Syncing Comments between Requested Item and Catalog Task
//Name: push comments to ritm
//Table: Catalog Task
//When: Before
//Insert: false
//Update: true
(function executeRule(current, previous /*null when async*/) {
try{
var sc_req_item = new GlideRecord('sc_req_item');
if(sc_req_item.get(current.request_item)){
sc_req_item.comments = current.comments;
@jacebenson
jacebenson / automatically_link.br.js
Last active November 26, 2018 16:40
Business rule to create links where other records are typed in
@assertivist
assertivist / snkeepalive.sh
Created August 28, 2017 19:57
keeps a ServiceNow developer instance awake, at least until the nightly snooze-all
#!/bin/bash
# put your instance id here
instance="dev######"
# make sure your password doesn't have shell operators in it
credentials="admin:password"
while true; do
entropy=`rand`
outdata="{\"short_description\":\"Automated incident $entropy\"}"