This file contains 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
//Client-side example usage | |
doThing(); | |
function doThing() { | |
new EfficientGlideRecord('incident') | |
.setLimit(10) | |
.addNotNullQuery('assignment_group') | |
.addField('number') | |
.addField('short_description') | |
.addField('assignment_group', true) //Get display value as well |
This file contains 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
copySpecificAttachment(donorTable, donorID, recipientTable, recipientID, fileName); | |
function copySpecificAttachment(donorTable, donorID, recipientTable, recipientID, fileName) { | |
var donorAttSysID, | |
grNewAttachment, | |
linkToNewRecord, | |
attDataRecord, | |
newDocRecord, | |
grAttachment = new GlideRecord('sys_attachment'); | |
grAttachment.addQuery('table_name', donorTable); |
This file contains 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
/* | |
Script Include definition: | |
Name: JournalRedactor | |
Client Callable: false | |
Accessible from: All application scopes | |
Additional details: | |
Version: 1.3 | |
Usage documentation: http://redactor.snc.guru/ | |
License: https://gist.github.com/thisnameissoclever/767b8a738b929a0bd943965431061c1e | |
*/ |
This file contains 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 the journal entries from a given record, and optionally parse and convert line breaks and | |
* HTML and wokkas (< and >) to HTML (<br />\n and HTML-ized character codes). | |
* @param {GlideRecord} current - A GlideRecord object positioned to the record you want to get the | |
* journal entries from. | |
* @param {String} journalFieldName - The journal field name (e.g. "work_notes", "comments", | |
* "comments_and_work_notes", etc.). | |
* @param {Boolean} [convertLineBreaksToHTML=false] - Set this to true, to convert line-breaks | |
* (\r\n) to HTML (<br />\n). | |
* @param {Boolean} [convertWokkasToHTML=false] - Set this to true, to convert wokkas ("<" and ">") |
This file contains 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
/** | |
* Local (instance-specific) System Property Script Include | |
* More info available at https://localprop.snc.guru | |
* | |
* A ServiceNow JavaScript ES5 class, LocalProperty, for getting and setting instance-specific | |
* system properties. | |
* See method documentation for more information. | |
* @param {string} [instanceNameOverride=] - Override the name of the instance that's currently | |
* executing this code. | |
* For example, if you have a system property such as "my_prod_instance.some_property" which |
This file contains 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
var methodsAndProperties = []; | |
var testObj = new GlideFilter('a=b', 'rule'); //TODO: replace this with whatever object you want to test | |
getMethodsAndProperties(methodsAndProperties, testObj); | |
gs.print('\n' + methodsAndProperties.join('\n')); | |
/** | |
* Populates an extant array in-place, of methods and properties of a given object. | |
* @param methodsAndProperties {array} - the array to populate/modify in-place. |
This file contains 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 openLatestPageVersion() { | |
var originalURL, pageNameIndex, pageNameEndIndex, pageName, latestURL; | |
originalURL = location.href; | |
if (!originalURL.toString().includes('docs.servicenow.com')) { | |
alert('This does not appear to be a ServiceNow Docs page. This button only works for pages on docs.servicenow.com.'); | |
return; | |
} | |
pageNameIndex = (originalURL.indexOf('/concept/') + 9); | |
pageNameEndIndex = (originalURL.indexOf('.html', pageNameIndex) + 5); | |
pageName = originalURL.substring(pageNameIndex, pageNameEndIndex); |
This file contains 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
var recordTable = 'incident'; | |
var idOfRecord = '755d52b137b0b30090b68cf6c3990e6f'; | |
var grAttachment = getAttachmentRecord(recordTable, idOfRecord, 'example text doc.txt', true); | |
if (grAttachment !== false) { | |
var attachmentStream = new GlideSysAttachment().getContentStream( | |
grAttachment.getValue('sys_id') | |
); | |
var gDigest = new GlideDigest(); | |
var base64MD5 = gDigest.getMD5Base64FromInputStream(attachmentStream); //Scope only | |
gs.info(base64MD5); |
This file contains 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 onChange(control, oldValue, newValue, isLoading, isTemplate) { | |
if (isLoading) { | |
return; | |
} | |
var scriptHasUncommentedLines, flyoutText; | |
var isAdvanced = (newValue === 'true'); | |
var origScriptVal = (g_form.getValue('script').trim()); | |
var doesScriptExist = (!!origScriptVal); |
This file contains 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
/** | |
* Show an animated loading message such as "Loading...", where the dots will be | |
* animated with the interval specified in msInterval; first showing "Loading.", then | |
* "Loading..", then "Loading...", up to the number of dots indicated in maxDots. | |
* Once maxDots is reached, the message will be reset to "Loading." and the animation | |
* will repeat until stopAnimatedLoadingMessage() is called. | |
* | |
* @param {String} fieldName - The name of the field on which to show the loading message. | |
* @param {String} messageText - The loading message to be shown, which will be followed | |
* by animated dots (or whatever character is specified in dotChar, if specified). |
NewerOlder