Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

On R1100, we are creating roles and groups in SN to ensure we grant My Approval widget access to people who need it.


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

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

  • No labels