0 votes
611 views
in Integrations by

1 Answer

0 votes
by (30.6k points)

Resolve the participant group (team) to its members and send one e-mail with all addresses (or one per member), using the members' e-mail attribute:

// service flow script: e-mail addresses of every member of a team / participant group
var team = tw.system.org.findRoleByName(tw.local.teamName);          // participant group / team by name (nested groups expanded by allUsers)
if (team == null) throw new Error("Team not found: " + tw.local.teamName);
var users = team.allUsers, addresses = [];
for (var i = 0; i < users.length; i++) {
  var mail = users[i].attributes.get("Email Address") || users[i].emailAddress;    // attribute name as in Process Admin; TWUser.emailAddress on newer releases
  if (mail && mail != "") addresses.push(String(mail));
}
tw.local.to = addresses.join(";");        // Send E-Mail accepts several recipients separated by ; (or , on some releases)
// then the System Data "Send E-Mail" service: to = tw.local.to, subject, body (HTML), from = tw.env.mailFrom

Variants: one personalised mail per member (loop over users and call Send E-Mail each time - slower but allows "Dear Ana"), BCC for large groups (the Send E-Mail service has bcc on BAW), and a distribution list address in the team's description as a fallback when the group is huge. For the team of a task (the potential owners of a specific task), read the task's team (tw.system.findTaskByID(id).assignedTo returns the user or the team) and resolve it the same way. Keep the team lookup cached when the mail is sent from a loop (LDAP cost).

References

Related questions

0 votes
1 answer 1.7k views
0 votes
1 answer 1.8k views
0 votes
1 answer 1.0k views
0 votes
1 answer 677 views
0 votes
1 answer 1.4k views
0 votes
1 answer 1.1k views
0 votes
1 answer 2.4k views
0 votes
1 answer 3.6k views
0 votes
1 answer 774 views
0 votes
1 answer 849 views
0 votes
1 answer 4.0k views

723 questions

807 answers

98 comments

4.9k users

Join BPM Community Discord Channel

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
Created by Dosvak LLC
Our Youtube Channel
...