Powershell script to to test simple lis
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
| (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
| //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
| 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
| 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
| /** | |
| * 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
| /** | |
| * Retrieves active user sessions and associated nodes for a list of user IDs. | |
| * | |
| * @param {string[]} userIDs - An array of user IDs for which to retrieve active sessions. | |
| * @returns {Object[]|undefined} - An array of session and node information, or undefined if no active sessions are found. | |
| */ | |
| function cf_getActiveUserSessions(userIDs) { | |
| /** | |
| * Internal function to get active sessions for given user IDs. |
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
| /** | |
| * Creates a new GlideRecord Object from inputs, calls query(), then retuns the Object | |
| * @private | |
| * @param {object} options - Object containing table and any gliderecord methods to call | |
| * @returns {GlideRecord} | |
| * @example | |
| * var options = { | |
| * "table": "cmdbi_ci_computer", | |
| * "methods": { | |
| * "addEncodedQuery": "active=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
| /** | |
| * Takes a nested object and flattens its to one level. Function recursively calls itself until finished. | |
| * //https://stackoverflow.com/questions/34513964/how-to-convert-this-nested-object-into-a-flat-object | |
| * @public | |
| * @param {Object} currentNode - Current node in the nested object to process | |
| * @param {object} flattenedObject - The new object containing the flattened values | |
| * @param {object} flattendKey - The current flattened key name. Example: key.key1.key2 | |
| * @returns {Object} | |
| * @example var testObj = { | |
| "key1" : "test1", |