Helper script include for dealing with variables in servicenow
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 emailScriptHelper = Class.create(); | |
| emailScriptHelper.prototype = { | |
| initialize: function() {}, | |
| varsToHTMLTable: function(variables) { | |
| if (variables == 'undefined') { | |
| return; | |
| } | |
| var helperOptions = {'useLable': true,'useDisplayValue': 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
| | |
| function validateQuery(grToCheck) { | |
| return grToCheck.isEncodedQueryValid(grToCheck.getEncodedQuery()); | |
| } | |
| function isNullOrEmpty(val) { | |
| return val == null || val == '' || val == 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
| function validateQuery(grToCheck) { | |
| return grToCheck.isEncodedQueryValid(grToCheck.getEncodedQuery()); | |
| } | |
| function isNullOrEmpty(val) { | |
| return val == null || val == '' || val == undefined; | |
| } | |
| function validateArgs() { |
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 excelToObject(attID) { | |
| if (!attID || !isValidSysId(attID)) { | |
| throw new Error("Valid attachment id required"); | |
| } | |
| var excelObj = []; | |
| var attachment = new GlideSysAttachment(); | |
| var attachmentStream = attachment.getContentStream(attID); |
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 SecretServer = Class.create(); | |
| SecretServer.prototype = { | |
| initialize: function() { | |
| this.BASE_URL = 'https://mySecretServer/SecretServer'; //temp change due to load balanced URL being down | |
| this.AUTH_PROFILE = 'SYSID'; //sys_id of basic auth profile | |
| this.TOKEN_CRED = this._getCredential(this.AUTH_PROFILE); //Glide Record of auth Profile | |
| this.ACCESS_TOKEN = ''; //Holder for Access Token |
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 recordToHTML = (function() { | |
| //class variables | |
| var exclusions = { | |
| "sections": [], | |
| "fields": [] | |
| }; | |
| /******************************** |
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 getCartItem = function (sys_id) { | |
| var gr = new GlideRecord("sc_cart_item"); | |
| gr.get(sys_id); | |
| return gr; | |
| }; | |
| var addAttToCartItems = function (items,cat_item) { | |
| var attachment = new GlideSysAttachment(); | |
| //set up inputs |
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 () { | |
| function newGrObject(tbl, obj) { | |
| var grRec = new GlideRecord(tbl); | |
| new GlideRecordUtil().mergeToGR(obj, grRec); | |
| grRec.insert(); | |
| } | |
| var oldUiPolicy = 'f6e44e7bdbc005101ad90cd7f4961916'; | |
| var newUiPolicy = '05610f08db50c5101ad90cd7f4961937'; | |
| var tbl = 'catalog_ui_policy_action'; |
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
| /** | |
| * Walks through an object using dot notation or an array of properties. This could be replaced by option chaining in ECMA2021 | |
| * @param {object} obj - The object to walk through. | |
| * @param {string | string[]} props - The dot notation string or array of properties to traverse. | |
| * @returns {*} - The value of the property at the end of the traversal, or undefined if not found. | |
| * @throws {Error} - Throws an error if the arguments are invalid. | |
| * @private | |
| */ | |
| function _dotWalkObject(obj, props) { | |
| var propsIsArray = Array.isArray(props); |
OlderNewer