How to Send Email Notification to members of Group,its child group and its grand child group dynamically ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2014 02:31 AM
Hiiiii,
I have a from with Inclusion List which is referring to Group table and a Message to be broadcast ed. I need to broadcast a message to all the members of selected Main group,its child group and its grand child group and so on.......
I created a workflow to broadcast on approval of hr. I need to specify all the group and its child group . That is static.
Can anyone tell me how to do it dynamically ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2014 02:47 AM
Hi,
Try selecting To(Script) at the bottom of the notification activity,which will show you a box where you can script to get the groups and sub-groups.Set all the sys ids to answer.
Refer Re: Re: Dynamically add "To" address in workflow notification
Thanks!!.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2014 05:12 AM
this works for me ... gets the groups , members and unique members .. use what fits your requirement....
var parentGroupSysID = '1c590685c0a8018b2a473a7159ff5d9a';
var childGroupSysID = '';
var groupSysIDs = [];
var parentClass = '';
var continueTraverse = true;
var groupMembers = [];
var uniqueGroupMembers = [];
var arrayUtil = new ArrayUtil();
groupSysIDs.push(parentGroupSysID);
while(continueTraverse)
{
childGroupSysID = getGroupSysID(parentGroupSysID);
if(JSUtil.notNil(childGroupSysID))
{
groupSysIDs.push(childGroupSysID);
parentGroupSysID = childGroupSysID;
childGroupSysID = '';
}
else
{
continueTraverse = false;
}
}
gs.addInfoMessage("All Groups:"+groupSysIDs.toString());
var getMembers = new GlideRecord('sys_user_grmember');
getMembers.addQuery('group','IN',groupSysIDs.toString());
getMembers.query();
while(getMembers.next()){
groupMembers.push(getMembers.getValue('user'));
}
uniqueGroupMembers = arrayUtil.unique(groupMembers);
gs.addInfoMessage("Members:"+ groupMembers.toString());
gs.addInfoMessage("Unique Members:"+ uniqueGroupMembers.toString());
function getGroupSysID(parentID)
{
var id = '';
var getChildGroups = new GlideRecord('sys_user_group');
getChildGroups.addQuery('parent',parentID);
getChildGroups.query();
if(getChildGroups.next())
{
id = getChildGroups.getValue('sys_id');
}
return id;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2014 12:01 AM
just curious , if it solved your problem ...