Skip to content

Instantly share code, notes, and snippets.

@cmcdevitt
Last active June 27, 2022 21:53
Show Gist options
  • Select an option

  • Save cmcdevitt/bdc525b692c86d97b21b4cbd7060f78d to your computer and use it in GitHub Desktop.

Select an option

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
/*
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