In a background script, how do I get the display name?

Robert Campbell
Tera Guru

I want to show all groups in the sys_user_grmember table but I only want to show them once. I want to show the name, not the sys_id of the group and especially not the sys_id of the grmember record.

 

var gm = new GlideAggregate('sys_user_grmember');
var gmresults = [];

gm.addAggregate('COUNT','group');
gm.groupBy('group');
gm.sortBy('group');
gm.query();

while(gm.next()){
  gs.print(gm.group.name.toString());
}

Shows results but no value at all.

*** Script: 
Adding an NAE keystore
Adding an NAE keystore
KMF with KeySecure is enabled
*** Script: 
Adding an NAE keystore
Adding an NAE keystore
KMF with KeySecure is enabled
*** Script: 
Adding an NAE keystore
Adding an NAE keystore
KMF with KeySecure is enabled
*** Script: 
Adding an NAE keystore
Adding an NAE keystore
KMF with KeySecure is enabled
*** Script: 
Adding an NAE keystore

 

var gm = new GlideAggregate('sys_user_grmember');
var gmresults = [];

gm.addAggregate('COUNT','group');
gm.groupBy('group');
gm.sortBy('group');
gm.query();

while(gm.next()){
  gs.print(gm.group.toString());
}
[0:00:00.006] Expanding large row block (file.read: sys_user_grmember, 10000 rows, 1440000 dataSize)
[0:00:00.016] Compacting large row block (file.write: sys_user_grmember 7648 rows 1101576 saveSize)
*** Script: aae437fd472c211074770184f16d43ac
*** Script: 01d0db9647b0e11074770184f16d43e3
*** Script: 06017d76870fa99054260ed4dabb353b
*** Script: bfa33f35472c211074770184f16d4360
*** Script: 2b84f33d472c211074770184f16d437a
*** Script: e58a8a1947936910376d4c38436d43f5
*** Script: 51e473fd472c211074770184f16d43ef
*** Script: 80063739476c211074770184f16d4393
*** Script: a7125b1247f0e11074770184f16d4394
*** Script: b7e25f9647f0e11074770184f16d43e0
*** Script: c812931247f0e11074770184f16d43f9

This shows the sys_id but I'm not sure if it's the sys_id of the sys_user_grmember record or the sys_id of the group (sys_user_group.sys_id).  Either way, I want the name that is displayed for the group on the sys_user_grmember record.

1 ACCEPTED SOLUTION

Sainath N
Mega Sage
Mega Sage

@Robert Campbell : Below is the updated code that prints the group name instead of sys_id.

var gm = new GlideAggregate('sys_user_grmember');
var gmresults = [];

gm.addAggregate('COUNT', 'group');
gm.groupBy('group');
gm.sortBy('group');
gm.query();

while (gm.next()) {
    gs.print(gm.group.getDisplayValue().toString());
}

 

Sample screenshot from my execution:

 

sainathnekkanti_0-1703279908396.png

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

View solution in original post

1 REPLY 1

Sainath N
Mega Sage
Mega Sage

@Robert Campbell : Below is the updated code that prints the group name instead of sys_id.

var gm = new GlideAggregate('sys_user_grmember');
var gmresults = [];

gm.addAggregate('COUNT', 'group');
gm.groupBy('group');
gm.sortBy('group');
gm.query();

while (gm.next()) {
    gs.print(gm.group.getDisplayValue().toString());
}

 

Sample screenshot from my execution:

 

sainathnekkanti_0-1703279908396.png

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.