How to Send Email Notification to members of Group,its child group and its grand child group dynamically ?

anithar
Kilo Explorer

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 ?

3 REPLIES 3

jsi
Mega Guru

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!!.


Kalaiarasan Pus
Giga Sage

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;


}


just curious , if it solved your problem ...