Versions Compared

Key

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

...


We need a way of querying who should have that access:

 

...

Code Block

...

var role = "u_bolt_member";

...


gs.print("querying for " + role);

...


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

...


gr.addAggregate('count'); //Count aggregate (only necessary for a count of items of each OS)

...


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

...


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

...


gr.query();

...


var total = 0;

...


while(gr.next()){

...


   var person = gr.u_bolt_member;

...


   var boltCount = gr.getAggregate('count'); //Get the count of the OS group

...


   //Print the OS name and count of items with that OS

...


  // gs.print('Distinct bolt people: ' + gr.u_head + ': ' + boltCount);

...


   var guser = new GlideRecord('sys_user'); // user query

...


   guser.addQuery('sys_id',person);

...


   guser.query();

...


   guser.next();

...


   var netid = guser.user_name;

...


//   gs.print(gr.u_head + " maps onto netid: " + netid);

...

 
//   gs.print(netid);

...

 
   total++;

...


}

...


gs.print("total is: " + total);

...


var role = "u_head";

...


////////////////////////

...


gs.print("querying for " + role);

...


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

...


gr.addAggregate('count'); //Count aggregate (only necessary for a count of items of each OS)

...


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

...


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

...


gr.query();

...


var total = 0;

...


while(gr.next()){

...


   var person = gr.u_bolt_member;

...


   var boltCount = gr.getAggregate('count'); //Get the count of the OS group

...


   //Print the OS name and count of items with that OS

...


  // gs.print('Distinct bolt people: ' + gr.u_head + ': ' + boltCount);

...


   var guser = new GlideRecord('sys_user'); // user query

...


   guser.addQuery('sys_id',person);

...


   guser.query();

...


   guser.next();

...


   var netid = guser.user_name;

...


//   gs.print(gr.u_head + " maps onto netid: " + netid);

...

 
//   gs.print(netid);

...

 
   total++;

...


}

...


gs.print("total is: " + total);

...


//////////////////

...


var role = "u_opsmgr";

...


gs.print("querying for " + role);

...


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

...


gr.addAggregate('count'); //Count aggregate (only necessary for a count of items of each OS)

...


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

...


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

...


gr.query();

...


var total = 0;

...


while(gr.next()){

...


   var person = gr.u_bolt_member;

...


   var boltCount = gr.getAggregate('count'); //Get the count of the OS group

...


   //Print the OS name and count of items with that OS

...


  // gs.print('Distinct bolt people: ' + gr.u_head + ': ' + boltCount);

...


   var guser = new GlideRecord('sys_user'); // user query

...


   guser.addQuery('sys_id',person);

...


   guser.query();

...


   guser.next();

...


   var netid = guser.user_name;

...


//   gs.print(gr.u_head + " maps onto netid: " + netid);

...

 
//   gs.print(netid);

...

 
   total++;

...


}

...


gs.print("total is: " + total);

...

results:

*** Script: querying for u_bolt_member
*** Script: total is: 7
*** Script: querying for u_head
*** Script: total is: 75
*** Script: querying for u_opsmgr
*** Script: total is: 115

...