Last active
June 27, 2022 21:53
-
-
Save cmcdevitt/bdc525b692c86d97b21b4cbd7060f78d to your computer and use it in GitHub Desktop.
Uses Teams [cmdb_rel_team] - Related List on Configuration Item for VR Assignment Rules
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 | |
| function getAssignment(ci,group_type){ | |
| /* | |
| ci(string) expects the sys_id of a Configuration Item | |
| group_type(string) expects that value of Group Type (Choice List) | |
| */ | |
| //Testing,pick an Assignment Group | |
| var default_assignment_group = '679434f053231300e321ddeeff7b12d8'; | |
| //use gs.getProperty() for real | |
| //var default_assignment_group = gs.getProperty(''); | |
| var teams = new GlideRecord('cmdb_rel_team');//Teams Table | |
| teams.addEncodedQuery('group_type=' + group_type + '^ci=' + ci); | |
| teams.setLimit(1); | |
| teams.query(); | |
| while(teams.next()){ | |
| return teams.user_group; | |
| } | |
| /* | |
| Else Return a Default Assignment Group | |
| If the Conditions in an Assignment Rule match, VR expects an Assignment Group | |
| if no assignment group is provided, the VI will NOT be assigned. | |
| */ | |
| return default_assignment_group; | |
| } | |
| current.assignment_group = getAssignment(current.cmdb_ci,'security'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment