Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

There is a cleaner way to do this, but here's one way to get this list:

Code Block



var gr2 = new GlideRecord('sys_user_role');

gr2.addQuery('name','itil');

gr2.query();

if (gr2.next() ) {
  gs.print('itil group sysid is: ' + gr2.sys_id);

}




//var gr = new GlideAggregate('sys_user'); //GlideAggregate query

var gr = new GlideRecord('sys_user');

gr.addQuery('roles','CONTAINS',gr2.sys_id);

//gr.orderByAggregate('count'); //Count aggregate ordering

//gr.groupBy('email'); //Group aggregate by the 'os' field

gr.query();

var count = 0;

while(gr.next()){
 //Print the OS name and count of items with that OS
 // gs.print('Distinct operating system: ' + gr.os + ': ' + osCount);
 count++;

}

gs.print('count is: ' + count);




var gr3 = new GlideRecord('sys_user_has_role');

gr3.addQuery('role',gr2.sys_id);

gr3.query();

var count2 = 0;

while ( gr3.next() ) {
 count2++;

}

gs.print('aoeuaoeeaoeoa count: ' + count2);




var gr4 = new GlideAggregate('sys_user_has_role');

gr4.addQuery('role',gr2.sys_id);

gr4.groupBy('user');

gr4.query();

var count3=0;

while (gr4.next()) {
  gs.print('one user record is: ' + gr4.user.email);
  count3++;

}

gs.print('4p,p,.puixx.eu count: ' + count3);

...