
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2016 07:17 AM
In a Change Request form, users can select which department groups should review the proposed changes. This can be up to 11 groups.
Since many of the group members are in several of these groups, I need to add each of the members of the selected groups so they only get one email from this notification. I already have the id of all the groups. Can I use an array for the member's email and add this array to in the Notification script (Advanced)? If so, what is the field I will set in Notification? What is the best way to get the user's email via the group members?
Thanks in advance!
Mike
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2016 09:31 AM
Hi Mike,
Let's make an array of objects. I've also put the values in the bold line for you.
if(current.u_it_services == 'Yes'){
getMembers('25c64ce70d431200083ba4f662762aab');
}
var uList = getMembers(groupID);
gs.log("userList: "+userList);
function getMembers(groupID){
var userList = [];
var mem = new GlideRecord('sys_user_grmember');
mem.addQuery('group', groupID);
mem.query();
while (mem.next()){
var uObj = {};
uObj.id = mem.getValue('user');
uObj.name = mem.user.getDisplayValue();
userList.push(uObj);
//email.addAddress("cc", mem.getValue('user'), mem.user.getDisplayValue());
}
return userList;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2016 11:18 AM
I'm glad you got your question answered. Would you please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
If you are viewing this discussion from your "inbox", use the "mark as correct" option under actions. If you are viewing it directly from the thread use the Correct Answer link (red with a star).
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2022 10:10 AM
Hi Chuck,
I am stuck with a requirement to send emails to the Case account team member whose responsibility is 'Account Manager'. Below script is not working for me, can you please help
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
var groupMembers = new GlideRecord('sn_customerservice_team_member');
groupMembers.addQuery('account', current.account.sys_id);
groupMembers.addEncodedQuery('responsibility=d151dbgeddbt654d49d2dce46ld786fg3'); //Responsibility is Account Manager
groupMembers.query();
while (groupMembers.next()) {
email.addAddress("cc", groupMembers.getValue('user'), groupMembers.user.getDisplayValue());
}
})(current, template, email, email_action, event);