This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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'); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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\"}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function(){ | |
| var text = ""; | |
| var printl = function(str){ | |
| text = text + str + '\n'; | |
| }; | |
| var println = function(str) { | |
| if(str){ | |
| text = text + str + '\n\n'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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(); |