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
| /** | |
| * Used to validate arguments passed into methods. | |
| */ | |
| var argumentValidation = Class.create(); | |
| argumentValidation.prototype = { | |
| initialize: function(logLevel) { | |
| this.logger = new global.GSLog('cf.argumentValidation.log.level'); | |
| if (this.notNil(logLevel)) { | |
| logger.setLevel(logLevel); |
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 f1(a) { | |
| gs.info("Hello " + a); | |
| return gs.now(); | |
| } | |
| function f2(a) { | |
| gs.info("The date is: " + a); | |
| return 70; | |
| } | |
| function f3(a) { | |
| gs.info("The temperature is " + a + " degrees"); |
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; This is a work in progress and has not been tested in its current form. | |
| * Set of methods to simplify loading data into ServiceNow. Use with Inbound Email, rest, etc... | |
| * A temporary DS/importset will be created for the data load. It will be removed if the cleanup method is called. | |
| * Example usage: DataTransformUtils().getDataSourceByName('Test DataSource').copyDataSource().copyAtt(sourceRecord).loadData().getMapByName('Test Transform Map').importData().cleanUpImport().log(); | |
| * this will: | |
| * 1. Retrieve Existing DS by name | |
| * 2. Create a clone of this datasource | |
| * 3. Copy attachments from a source record to copied datasource | |
| * 4. load data from the datasource into the import set table |
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 cf_ClientCommonsAjax = Class.create(); | |
| cf_ClientCommonsAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, { | |
| /** | |
| * Dot walk object until last property reached | |
| * @param {Object} obj obj | |
| * @param {Array} props array of object properties | |
| * @returns the last object value | |
| */ |
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
| //copy variables from ritm to change request form | |
| var ritmVar = new GlideRecord('sc_item_option_mtom'); | |
| ritmVar.addQuery('request_item', current.getUniqueValue()); | |
| ritmVar.addNotNullQuery('sc_item_option.value'); | |
| ritmVar.orderBy('sc_item_option.order'); | |
| ritmVar.query(); | |
| var chgVar = new GlideRecord('question_answer'); | |
| chgVar.newRecord(); | |
| chgVar.table_name = 'change_request'; |
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() { | |
| var comment = "Workflow cancelled by " + gs.getUserDisplayName(); | |
| new WorkflowApprovalUtils().cancelAll(current, comment); | |
| new Workflow().restartWorkflow(current); | |
| current.work_notes = comment; | |
| //cancel current flow context and start new | |
| if (!current.cat_item.flow_designer_flow.nil() && !current.flow_context.nil()) { |
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
| /** | |
| * DataTransformRecord Class | |
| * Manages the lifecycle of data transformation in ServiceNow by automating the creation, manipulation, | |
| * and cleanup of data sources and associated transform maps. | |
| * | |
| * @class | |
| */ | |
| var DataTransformRecord = function() { | |
| var datasource; | |
| var map; |
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); |
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
| 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 |