- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 07:41 AM
Hi All,
Is there any js-function to get the user list object by group-name or is there any script to get all users from a group?
example group name is: IS&T Senior Leadership Team
Thanks & Regards,
Kiran Pedduri
Solved! Go to Solution.
- 29,663 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 08:15 AM
Hi Kiran,
Sorry, I had an error in the first one. I was pushing the sys_id of the membership record, not the users. I've corrected it.
Easy change... You can 'dot-walk' to get that. If you want the user_name field (labeled User ID, like chuck.tomasi) you can change the answer.push() line to this
answer.push(mem.user.name.toString()).
You want the email,answer.push(mem.user.email.toString());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 11:29 PM
OR try this,
function getMemberSysIds(groupName) {
var answer = [];
var mem = new GlideRecord('sys_user_grmember');
mem.addQuery('group.name', 'IS-HOSTING-SSOIN-WINTEL-DC-Global');
mem.query();
while (mem.next())
answer.push(mem.user.email.toString());
gs.print(answer);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 11:40 PM
HI Shishir,
It is showing empty when i execute
I think in this line i removed ".name"---------------- mem.addQuery('group.name', 'IS-HOSTING-SSOIN-WINTEL-DC-Global');
i replaced to mem.addQuery('group', 'IS-HOSTING-SSOIN-WINTEL-DC-Global');
because in "sys_user_grmember" the field name is only "group"
please correct me if i am wrong. infact i tried your script but also it is showing empty after execution

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 11:43 PM
No, please use with name, group field is not a string field on sys_user_grmember table, it is actually referenced to sys_user_group table.
mem.addQuery('group.name', 'IS-HOSTING-SSOIN-WINTEL-DC-Global');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2018 01:17 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2018 05:51 AM
In background script, you do not need to wrap under the function, please try below it will work in background script.
var answer = [];
var mem = new GlideRecord('sys_user_grmember');
mem.addQuery('group.name', 'IS-HOSTING-SSOIN-WINTEL-DC-Global');
mem.query();
while (mem.next())
answer.push(mem.user.email.toString());
gs.print(answer);