How to add users of a particular group to recipient list in targeted communication

Apurva Jogal
Kilo Sage

Hi, 
I am trying to create a Recipient List for Targeted Communication which should have recipients from a user group "xyz". 
Can you suggest how to achieve this?

1 ACCEPTED SOLUTION

AnveshKumar M
Tera Sage
Tera Sage

Hi @Apurva Jogal 

You can use script type to add users from a group to recipient list, provided the group members are one of the entity like contact, company/account, consumer, and internal user

 

Follow the steps:

 

1. Select Dynamic Condition in the Method field on the Recipients List form

2. Enable the Show Script check box.

3. Then create your script in the Script field to return array of sys_ids.

 

var memGr = new GlideRecord("sys_user_grmember");

memGr.addQuery("group.name", "Your GROUP NAME");

memGr.query();

var members = [];

 

while(memGr.next()){

   members.push(memGr.user + '');

}

return members;

 

 

Please mark my answer helpful and accept as solution if it helped you 👍

Thanks,
Anvesh

View solution in original post

3 REPLIES 3

AnveshKumar M
Tera Sage
Tera Sage

Hi @Apurva Jogal 

You can use script type to add users from a group to recipient list, provided the group members are one of the entity like contact, company/account, consumer, and internal user

 

Follow the steps:

 

1. Select Dynamic Condition in the Method field on the Recipients List form

2. Enable the Show Script check box.

3. Then create your script in the Script field to return array of sys_ids.

 

var memGr = new GlideRecord("sys_user_grmember");

memGr.addQuery("group.name", "Your GROUP NAME");

memGr.query();

var members = [];

 

while(memGr.next()){

   members.push(memGr.user + '');

}

return members;

 

 

Please mark my answer helpful and accept as solution if it helped you 👍

Thanks,
Anvesh

Apurva Jogal
Kilo Sage

Thank you @AnveshKumar M.

I just changed the script  - members.push(memGr.user + ''); to  members.push(memGr.user.sys_id + '');

and it worked.

@Apurva Jogal that's quick fix 👍

Thanks for sharing this info so that future readers can benefit from this.

Thanks,
Anvesh