ServiceNow: System Maintenance

Groups - no members


var grGroups= new GlideRecord('sys_user_group');
grGroups.addActiveQuery();
grGroups.query();
var iCounter=0;
gs.print('**START: total active groups is ' + grGroups.getRowCount());
while (grGroups.next()){

    var grGrpMemb=new GlideRecord('sys_user_grmember');
    if (!grGrpMemb.get('group', grGroups.sys_id)){
       gs.print(grGroups.name + ' has no members, please check');
       iCounter++;
    }
}

gs.print('**END: ' + iCounter + ' groups have no members');

Comments

Popular posts from this blog

GlideRecord setValue

variable advanced reference qualifier example

Running transform maps asynchronously