Background script to get list of groups with ITIL role

gunashalini
Tera Contributor

I need a background script such that it should provide a list of groups that have ITIL role under two cases.

1. ITIL role directly added to the group
2. ITIL role contained in another role and that role is added to the group

1 ACCEPTED SOLUTION

yaswanthi2
Giga Sage

Hi @gunashalini 

Please try like this you will get list of groups

 

var gr = new GlideRecord('sys_group_has_role');
gr.addEncodedQuery('roleLIKEext.resMgr^ORroleLIKErestMgrMain'); // apply filter of what roles you need to query from above table then copy the query and call in encoded query
gr.query();
while(gr.next()){
gs.print(gr.group.getDisplayValue()); // get list of group names that have ITIL role
}

View solution in original post

2 REPLIES 2

yaswanthi2
Giga Sage

Hi @gunashalini 

Please try like this you will get list of groups

 

var gr = new GlideRecord('sys_group_has_role');
gr.addEncodedQuery('roleLIKEext.resMgr^ORroleLIKErestMgrMain'); // apply filter of what roles you need to query from above table then copy the query and call in encoded query
gr.query();
while(gr.next()){
gs.print(gr.group.getDisplayValue()); // get list of group names that have ITIL role
}

gunashalini
Tera Contributor

Thanks for your help @yaswanthi2