Getting members names and emails of a group via script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2012 05:03 AM
How I can get member names and their emails of a specific group via script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2012 06:20 AM
Do you need to get this information via a script? You could set up a report on the user role table and set your needed filters and get the information that way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2012 02:19 AM
yes, I need this via script. Requirement is something like - moment I will select the assignment group, based on selective company, group members of that assignment group will automatically be added as watch list member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2012 11:58 PM
this can be done via the sys_user_grmember_list table. Based on the group you can query all the group members and put them in the watchlist. put the members in a new array and join them with the watchlist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2013 04:16 PM
I had this same question, and couldn't really find the answer anywhere, but the mention above of the sys_user_grmember table (we don't have a sys_user_grmember_list table) led me down a path of discovery and I was able to come up with a script to do just this. We needed to do this in case there was no DL associated with a group. Here is what I came up with:
<mail_script>
if (!current.group_list.nil()) {
//get group list addresses and add to cc
var groupers = current.group_list.split(",");
var gl = groupers.length;
for (var j = 0; j < gl; j++) {
//get guser records
var guser = new GlideRecord("sys_user_group");
guser.addQuery("sys_id", groupers[j]);
guser.query();
while (guser.next()) {
if (guser.email != "") {
//add to cc list
email.addAddress("cc", guser.email, guser.getDisplayValue());
//email.addAddress("bcc", guser.email, guser.getDisplayValue());
} else {
var gmembers = new GlideRecord("sys_user_grmember");
gmembers.addQuery("group.sys_id", groupers[j]);
gmembers.addQuery("user.notification", 2); //email
gmembers.addQuery("user.email", "!=", "");
gmembers.query();
while (gmembers.next()) {
email.addAddress("cc",gmembers.user.email, gmembers.user.getDisplayValue());
}
}
}
}
}
</mail_script>