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
| /* | |
| 1. Grant the user the Analysts role, for example: sn_vul.vulnerability_analyst | |
| 2. Grant the user the NEW BU Analysts role (that you created for this), for example: sn_vul.vulnerability_bu_analyst | |
| Note: the new role does not need to have any ACLs or anything else | |
| 3. Create an On Before, Query Business Rule (Order 10,000) | |
| */ | |
| gs.getUser().hasRole('sn_vul.vulnerability_bu_analyst');// <== BR Condition, only run this for BU Analysts | |
| //In canned BR function | |
| if(!gs.hasRole('admin')){//Don't run it for Admins |
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
| /* | |
| ==> (1) Script Action <== | |
| Script Actions seem slow and difficult to troubleshoot | |
| So.... Lets move the logic to a Script Include where we can simulate and troubleshoot a lot easer... | |
| *// | |
| //In Script Action example.... | |
| var util = new global.ChangeRequestUtil(current,event);// <== Pass in current and event as args when instantiating the SI | |
| util.utilKnows(); //Then call methods without arguments becouse the SI already know about current and event | |
| util.fooBar(); | |
| //... |
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 gr = new GlideRecord("sn_sec_cmn_src_ci"); | |
| gr.addEncodedQuery("osSTARTSWITHorg.mozilla.javascript.NativeArray"); | |
| //gr.setLimit(100); | |
| gr.query(); | |
| while (gr.next()) { | |
| var sourceData = JSON.parse(gr.getValue("source_data")); | |
| var os = sourceData["operating_system"]; | |
| if (os) { | |
| //"operating_system" object found in Source 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
| /* | |
| How to call the Script Include | |
| var util = new sn_vul.TaniumUtilities(); | |
| var out = util.login(); | |
| This requires a REST Message called "Tanium" | |
| HTTP Method: (POST) Login, Endpoint: ${baseURL}/api/v2/session/login, Authentication type: No authentication | |
| Note: You may need use select a MID server if this is on Prem (HTTP Method -> HTTP Request: Use MID Server | |
| */ | |
| var TaniumUtilities = Class.create(); |
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 ChainIt = Class.create(); | |
| ChainIt.prototype = { | |
| initialize: function() { | |
| //Persistence varables go here.... maybe an object | |
| this.answer = ''; | |
| }, | |
| addAnswer: function(add_it){ | |
| //add_it = string | |
| this.answer = add_it; |
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
| /* | |
| Database View[sys_db_view] | |
| Field Name[name] | |
| View Tables [sys_db_view_table] | |
| View [view] -> Database View | |
| View Fields [sys_db_view_table_field] | |
| View Table [view_table] -> View 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
| /* | |
| On a Configuration Item Table (i.e. CMDB) you can add a Teams[cmdb_rel_team] you can add a "Teams" Related List that can hold | |
| multiple Assignment Groups. | |
| This is how you access it in an assignment Rule | |
| */ | |
| function getAssignment(ci,group_type){ | |
| var default_assignment_group = '679434f053231300e321ddeeff7b12d8';//Set with gs.getProperty() | |
| var teams = new GlideRecord('cmdb_rel_team');//Teams Table | |
| teams.addEncodedQuery('group_type=' + group_type + '^ci=' + ci); | |
| teams.setLimit(1); |
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
| //Get the DOM Element and it's undocumented | |
| var subcat = g_form.getElement('subcategory');//Any "Choice" List | |
| if(subcat.length > 1){ // i.e. it's not Empty | |
| //Do something cool! | |
| }else{ | |
| //Do something cool! | |
| } | |
| /* | |
| Choice List are HTML Options |
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
| checkDateFormat: function(date) { | |
| //A very simple regex to see if the incoming data is compatable with the SN Date field | |
| var answer = false; | |
| var regexps = /[0-9]{4}-[0-9]{2}-[0-9]{2}/; // example 2022-02-28 | |
| if (regexps.test(date)) { | |
| answer = true; | |
| } | |
| return answer; |
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://docs.servicenow.com/bundle/tokyo-servicenow-platform/page/product/configuration-management/reference/r_RelatedListsOfCIComponents.html | |
| Docs: Related Lists of CI components | |
| Use Case | |
| You can not add an Assignment Group to the CMDB, and you want to use the 'Teams' CI Related List instead | |
| */ | |
| //Assignment Rule :: Assign Using :: Script |