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
| //Top of Script / Function / Method | |
| var start; | |
| var end; | |
| var dur; | |
| start = new GlideDateTime(); | |
| // Function OR Method between start and end | |
| end = new GlideDateTime(); | |
| dur = GlideDateTime.subtract(start, end); |
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
| /* | |
| Run in a BackGround Script or a Fix Script | |
| closed_at Type = Date/Time | |
| */ | |
| vit = 'e3ef3a1787fd91102d0b422e0ebb3551';//sys_id of a VIT:: VIT0014433 | |
| var gdt = new GlideDateTime("2022-12-14 08:00:01");//Set the time you want here | |
| var vi = new GlideRecord('sn_vul_vulnerable_item');//GlideRecord | |
| vi.get(vit); | |
| vi.setValue('closed_at', gdt); | |
| vi.update(); |
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 SIRUTILS = Class.create(); | |
| SIRUTILS.prototype = { | |
| initialize: function() {}, | |
| canReopenSIR: function( /*GlideRecord*/ incident) { | |
| /* | |
| Call this in UI Action Condition: | |
| new sn_si.SIRUTILS().canReopenSIR(current) | |
| */ | |
| var hasRole = gs.hasRole('itil'); //pick a better role |
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
| /* | |
| ServiceNow Vulnerability Response Exception Questionnaire | |
| 1. 'Assessment Instance Questions' [asmt_assessment_instance_question] table is populated with the Assessment Instance Questions | |
| 1.a. Keyfields: Source, Souce Table, Metric, Instance | |
| 2. The 'State Change Approval'[sn_vul_change_approval] table is populated with that Approval info AND | |
| 2.a Keyfield Questionnair [assessment_instance] | |
| 3. You need a way to associate the Assessment Instance Questions back to the triggering event | |
| 3.a Example: State Change Apprval KNOWS about the Assessment Instance via the Questionnair [assessment_instance] field | |
| 4. You will need to work "backwords" from the Assessment Instance Question table | |
| 4.a A Business Rule: "Before - Insert" :: Condition Source[source_id] is <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
| /* | |
| Stop form submission if fields are invalid | |
| UI Type: All | |
| Type: onSubmit | |
| */ | |
| function onSubmit(){ | |
| //Get Fields to Test | |
| var valid = g_form.getValue('group_name_available'); | |
| //Test Fields | |
| if('false' == valid){ |
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
| new sn_sec_cmn.CILookupUtil().updateReapplyFlag(); | |
| var ciLookupUtil = new sn_sec_cmn.CILookupUtil(); | |
| var utils = new sn_sec_cmn.BackgroundJobUtils(); | |
| ciLookupUtil.createBackgroundJob(); | |
| var jobGr = utils.getQueuedJob('Reapply CI lookup rules'); | |
| gs.info("This is the queued job " + jobGr.number); | |
| try{ | |
| var message = ciLookupUtil.getStats(); | |
| gs.info("Ci lookup stats" + message); |
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
| /* | |
| Widget Client Script | |
| I am not a SN Portal person so take this with a grain of salt! | |
| */ | |
| function($scope) { | |
| /* widget controller */ | |
| var c = this; | |
| c.config = { |
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 process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { | |
| //var util = new global.ChangeRequestAPI(); | |
| var requestBody = request.body; //Already parsed from JSON to object | |
| var requestData = requestBody.data; | |
| if (requestData) { | |
| //Get Input Data | |
| var change_request = requestData.u_change_request;//"standard" | |
| //Process Data |
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
| /* | |
| **** Client Script **** | |
| Name: CM Ajax Test | |
| Table: Incident [incident] | |
| UI Type: All | |
| Type: On Load | |
| Application: Global | |
| Active, Inherited, Global: True (checked) | |
| */ | |
| //Script |
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
| // https://joshneri.us/serverside-hasroleexactly-in-servicenow/ | |
| function hasRoleExactly(role) { | |
| var au = new ArrayUtil(); | |
| var roles = gs.getSession().getRoles() + ''; | |
| var roleArray = roles.split(","); | |
| var isAuthorized = au.contains(roleArray, role); | |
| return isAuthorized; | |
| } | |
| //or maybe |