- 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,660 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
‎05-31-2017 11:54 AM
Make two changes. First, don't get the user's name. List fields (like the watch list) are comma separated sys_ids. Change your answer.push() to this:
answer.push(mem.getValue('user'));
and return the comma separated list this way:
return answer.join(',');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 11:07 PM
Hi Tomasi,
I am trying the below script please check i am not getting users in the group
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( test);
}
return answer;
}
gs.print(test);
gs.print('test');
gs.print(answer);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 11:12 PM
Please have the group name in quotes.
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-06-2018 11:22 PM
HI Shishir,
I have given code as below, but i am getting error in back ground script, pl ind the below screen shot
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()) {
var test =answer.push(mem.user.email.toString());
gs.print( test);
}
//return answer;
}
gs.print(test);
gs.print('test');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 11:27 PM
you have to put test in quotes if test is not defined as variable. remove the gs.print(test) and just keep gs.print('test');