Skip to content

Instantly share code, notes, and snippets.

View nancystodd's full-sized avatar

Nancy S Todd nancystodd

View GitHub Profile

ServiceNow UI Developer cheat sheet


Utility URLs

URL Purpose
/stats.do Quick stats
/threads.do View active threads
@nancystodd
nancystodd / debugging_cheatsheet.md
Created October 25, 2019 23:59 — forked from iamwill/debugging_cheatsheet.md
Debugging on the Glide Platform

Debugging tips and tricks

Platform Troubleshooting

Console output too chatty?
Set com.glide.util.Log.developer_filter = true to cut down on non-interactive console log entries such as scheduled workers. (Don't forget to remove it when you're done!)

Utility urls

Note: Fast! These don't need a database.

@nancystodd
nancystodd / servicenow-scripting.md
Created October 24, 2019 00:40 — forked from animyeboah/servicenow-scripting.md
ServiceNow Developer Best Practices

GlideRecord

  • Use getUniqueValue to get sys_id.
  • Use newRecord instead of instantiating to get a new record with default values.
  • Dot-walking on GlideRecord returns GlideElement, use getRefRecord to get GlideRecord.

GlideForm

  • Use getBooleanValue for boolean fields.
@nancystodd
nancystodd / sample_restmessagev2.js
Created October 24, 2019 00:39 — forked from bryanbarnard/sample_restmessagev2.js
Sample RESTMessageV2 Parse JSON Response
// NOTE: this sample was run in a ServiceNow instance running release version Fuji Patch 4
(function sampleRequest() {
try {
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('get');
request.setEndpoint('https://rawgit.com/anonymous/f1c4664cafd6caf855fd/raw/f7ca3b022045e2c9f49dd2b453dea0cecc09888c/sample_json.json');
var response = request.execute();
var httpResponseStatus = response.getStatusCode();
@nancystodd
nancystodd / servicenow_restmessagev2_response_as_attachment.js
Created October 24, 2019 00:33 — forked from jnerius/servicenow_restmessagev2_response_as_attachment.js
Saving a RESTMessageV2 response as an attachment and getting the attachment's sys_id #ServiceNowSnippet
// This is where we'll save the attachment
var tablename = 'incident';
var recordSysId = '8d6353eac0a8016400d8a125ca14fc1f';
var filename = 'snlogo.png';
// Let's download the ServiceNow Logo
var logoUrl = 'https://instance.service-now.com/images/logos/logo_service-now.png';
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('get');
request.setEndpoint(logoUrl);
@nancystodd
nancystodd / SNAutoDoc5.js
Created October 24, 2019 00:33 — forked from eduglez/SNAutoDoc5.js
ServiceNow - Generate documentation in Markdown directly from the browser console
(function(){
var text = "";
var printl = function(str){
text = text + str + '\n';
};
var println = function(str) {
if(str){
text = text + str + '\n\n';
@nancystodd
nancystodd / snkeepalive.sh
Last active March 18, 2020 21:36 — forked from assertivist/snkeepalive.sh
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==$RANDOM
outdata="{\"short_description\":\"Automated incident $entropy\"}"
@nancystodd
nancystodd / servicenow_sample_http_request.js
Created October 24, 2019 00:28 — forked from bryanbarnard/servicenow_sample_http_request.js
sample http request in servicenow using RESTMessageV2 server side api tested running in ServiceNow Geneva Release as a background script in global scope
/**
* sample http request in servicenow using RESTMessageV2 server side api
* tested running in ServiceNow Geneva Release as a background script in global scope
*/
(function sample_http_request() {
try {
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('get');
request.setEndpoint('https://api.myjson.com/bins/4j985');
@nancystodd
nancystodd / SNow-StringifyGr.js
Created October 24, 2019 00:24 — forked from GenesisCoast/SNow-StringifyGr.js
Converts a ServiceNow glide record into a JSON string.
function stringifyGr(record) {
var result = ["{"];
var multiline = false;
for (var key in record) {
if(record.hasOwnProperty(key)) {
var value = record[key].toString();
switch (typeof value) {
case "undefined":
@nancystodd
nancystodd / getWorkflowByName_snippet.js
Created August 29, 2018 18:11
ServiceNow - Get a Workflow by Name
/**
* Get a Workflow by Name
* After dealing with how to find the correct sys_id for a workflow
* to use in a script, I found this snippet that made hard coding the
* sys_id a thing of the past.
*/
var wf = new Workflow();
wfId = wf.getWorkflowFromName('NAME OF WORKFLOW'));