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
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
//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
showSimpleLoadingMessage('Retrieving data'); | |
var arrListElements = slowFunctionThatReturnsAnArrayOfStrings() || ['Element 1', 'Element 2', 'Element 3']; | |
var flyoutListHTML = getHTMLListFromArray( | |
arrListElements, | |
'disc', | |
'Element: ' | |
); | |
g_form.clearMessages(); |
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 gaSlowGlideAjaxCall = new GlideAjax('{some_glideajax_script_include'); | |
//todo: Set the second argument to the method you want to execute from your GlideAjax Script Include | |
gaSlowGlideAjaxCall.addParam('sysparm_name', '{some_slow_glideajax_script_method'); | |
//todo: Add whatever other GlideAjax parameters you need to add below, such as: | |
gaSlowGlideAjaxCall.addParam('record_sys_id', g_form.getUniqueValue()); | |
gaSlowGlideAjaxCall.addParam('some_field_value', g_form.getValue('{field_name}')); | |
//Show animated form message: "Processing request..." | |
//This will continue to show and animate until we call stopAnimatedLoadingFieldMessage(), | |
// which we'll do in the callback function |
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 gaSlowGlideAjaxCall = new GlideAjax('{some_glideajax_script_include'); | |
//todo: Set the second argument to the method you want to execute from your GlideAjax Script Include | |
gaSlowGlideAjaxCall.addParam('sysparm_name', '{some_slow_glideajax_script_method'); | |
//todo: Add whatever other GlideAjax parameters you need to add below, such as: | |
gaSlowGlideAjaxCall.addParam('record_sys_id', g_form.getUniqueValue()); | |
//Show animated form message: "Processing request..." | |
//This will continue to show and animate until we call g_form.clearMessages(), | |
// which we'll do in the callback function | |
//todo: Update message from "Processing request" to whatever is appropriate to your situation. |
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). |
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
(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 message = ''; | |
message += 'This is an expanding info message. It can even run code! Click "Show more" to see!'; | |
message += '<div>'; | |
message += '<p><a href="#" onclick="javascript: jQuery(this.parentNode).next().toggle(200);">Show more</a></p>'; | |
message += '<div style="display: none;">'; | |
message += '<ul style="list-style: none">'; | |
message += '<li>This is the expanded info in the message.</li>'; | |
message += '<li>You can include any details you like here, including info retreived from a script like the sys_id of the current record: ' + g_form.getUniqueValue() + '</li>'; | |
message += '</ul>'; |
NewerOlder