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 tableName = 'incident'; | |
var recordID = '755d52b137b0b30090b68cf6c3990e6f'; | |
gs.print(getAttachmentContentsAsString(tableName, recordID)); | |
function getAttachmentContentsAsString(tableName, recordID) { | |
//Declare a new instance of GlideSysAttachment. | |
var gsa = new GlideSysAttachment(); | |
//Get the raw bytes in the file | |
var bytesInFile = gsa.getBytes(tableName, recordID); | |
//Convert that jive into a string using Java/Rhino. |
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
/** | |
* Does the work on each loop. | |
* @param {Number} [limit=10] - The number of records to process per loop. | |
* @param {Number} [currentNumber=0] - The number of records that have been processed so far, by all previous loops. | |
*/ | |
function eventWrapper(limit, currentNumber) { | |
var EVENT_NAME = 'EVENT.NAME.HERE'; //todo: Update this to the name of the event you've created. | |
var TABLE_NAME = 'TABLE_NAME_HERE'; //todo: Update this to the name of the table containing the records you're processing | |
var QUERY = 'some_query=here'; //todo: Put your query here |
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 DynamicRefQuals= Class.create(); | |
DynamicRefQuals.prototype = Object.extendsObject(AbstractAjaxProcessor, { | |
//Client-callable | |
/* | |
To quickly and easily create a dynamic reference qualifier script, simply add a custom method to this Script Include. | |
Here are the guidelines for modifying this Script Include: | |
1. In the "@author" JSDoc tag of the method your implement, please put your user ID (For example: "twoodruff"). | |
2. See how the getGroupMembersByID and getGroupMembersByName methods are documented, and try to document your method in the same fashion. | |
3. Unless you've got permission from the author, please do not modify anyone else's methods. |
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
/***CLASSES***/ | |
class APIClass { | |
/** | |
* An APIClass object | |
* @param name {string} The name of the API class | |
*/ | |
constructor(name, classDesc = '') { | |
this._className = name; | |
this._classDescription = classDesc; | |
/** |
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 deployDevConfig() { | |
_deactivateAllNonAdmins(); | |
_disableEmails(); | |
_setHeaderName(); | |
_deactivateLDAPServers(); | |
} | |
function _deactivateAllNonAdmins() { | |
var gr = new GlideRecord('sys_user'); | |
gr.addEncodedQuery('roles!=admin'); |
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
// 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 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 values of each URI param as properties of an object (name-value pairs). | |
* @param url | |
* @returns {{}} | |
* @example - In the URL www.google.com/page?urip=pickles&otheruriparam=bananas, you could use getAllUrlParams().urip to get "pickles". | |
*/ | |
function getAllUrlParams(url) { | |
// get query string from url (optional) or window | |
var queryString = url ? url.split('?')[1] : window.location.search.slice(1); |
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
/** | |
* Adds one object to another, nesting the child object into the parent. | |
* this is to get around javascript's immutable handling of objects. | |
* @param name {String} - The name of the property of the parent object, in which to nest the child object. <br />For example, if the name parameter is set to "pickles" then "parent.pickles" will return the child object. | |
* @param child {Object} - The object that should be nested within the parent object. | |
* @param [parent={}] {Object} - The parent object in which to nest the child object. If the parent object is not specified, then the child object is simple nested into an otherwise empty object, which is then returned. | |
* @returns {Object} - A new object consisting of the parent (or an otherwise empty object) with the child object nested within it. | |
* @example | |
* //sets myNewObject to a copy of originalObject, which now also contains the original (yet un-linked) version of itself as a child, under the property name "original" | |
* var myNewObject = addObjToObj("orig |
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
GlideSysAttachment.copy("ZZ_YYtable_name", "default_image_sys_id_here", "ZZ_YYtable_name", current.getValue('sys_id')); |
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 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? |