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 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 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
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>'; |
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 showMyForm(){ | |
var recordID = g_form.getUniqueValue() || "-1"; | |
var recordTableName = g_form.getTableName(); | |
var dialog = new GlideDialogForm('Update Record', recordTableName); | |
//Set to "-1" to show new record form instead | |
dialog.setSysID(recordID); | |
//If false, will show related lists as well. | |
dialog.addParm('sysparm_form_only', 'true'); | |
//todo: Form view? |
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
GlideSysAttachment.copy("ZZ_YYtable_name", "default_image_sys_id_here", "ZZ_YYtable_name", current.getValue('sys_id')); |
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
var BenchmarkRunner = Class.create(); | |
BenchmarkRunner.prototype = { | |
initialize : function () { | |
this.timers = {}; | |
}, | |
/** | |
* Execute two functions with the specified arguments, and get info about which was faster | |
* (and by how much). | |
* |
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
MIT License | |
Copyright (c) 2017 Timothy Woodruff | |
https://snprotips.com/ | |
This license applies to all public gists on https://gist.github.com/thisnameissoclever | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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
data.orgChart = data.orgChart || {}; | |
data.orgChart.tiers = data.orgChart.tiers || []; | |
data.orgChart.i18n = { | |
avatar: gs.getMessage("{0} avatar"), | |
directReport: gs.getMessage("{0} direct report"), | |
directReports: gs.getMessage("{0} direct reports"), | |
minimumCharacters: gs.getMessage("Please enter {0} or more characters") | |
}; | |
var loopDetected = false; |
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
var MSTeamsMessage = Class.create(); | |
MSTeamsMessage.prototype = { | |
/** | |
* | |
* @param {string} [teamsEndpoint=gs.getProperty()] - The MS Teams endpoint for the channel you're trying to post a message to. | |
* You can also specify this later by calling the .setEndpoint() method. | |
*/ | |
initialize : function (teamsEndpoint) { | |
//local init |
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
var exampleObj = { | |
"name": "Tim", | |
"age": 31, | |
"groovy": true, | |
"dogs": [ | |
{ | |
"name": "Ezri", | |
"age": 1 | |
}, | |
{ |
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: Read from innermost, outward | |
getAllUrlParams( | |
decodeURIComponent( | |
getAllUrlParams( //Get all URL params. Since SN re-encodes everything it passes into page processors like "nav_to.do" for example, this will have one key-val pair. | |
(this.location.href ? this.location.href : window.location.href) //The document URL. Should work for SP, and desktop view. | |
)['uri'] | |
) | |
); | |
var yourParamValue = getAllUrlParams(this.location.href)['YOUR_PARAM_NAME']; |