0 votes
3.5k views
in Process Center by (160 points)
In a variable named childGroups (which is a NameValuePair list) there are two Teams (groups).
I would like to create a service which accepts the input of childGroups and creates a NameValuePair list of all members from that two groups.

1 Answer

0 votes
by (30.6k points)

Resolve each team (participant group) to its members with the JavaScript API and merge the users into one NameValuePair list, de-duplicated by user name:

// service flow script; input tw.local.childGroups (NameValuePair list: name = team name), output tw.local.users (NameValuePair list)
var seen = {}, out = new tw.object.listOf.NameValuePair();
for (var i = 0; i < tw.local.childGroups.listLength; i++) {
  var team = tw.system.org.findRoleByName(tw.local.childGroups[i].name);   // participant group / team by name
  if (team == null) continue;
  var members = team.allUsers;                                            // TWUser[] (nested groups expanded)
  for (var j = 0; j < members.length; j++) {
    var u = members[j];
    if (seen[u.name]) continue;
    seen[u.name] = true;
    var nv = new tw.object.NameValuePair(); nv.name = u.name; nv.value = u.fullName; out.insertIntoList(out.listLength, nv);
  }
}
tw.local.users = out;

Notes:

  • findRoleByName works for teams defined in the process app / toolkit; for security groups (LDAP / internal groups) use tw.system.org.findRoleByName as well - BPM treats them the same - or tw.system.org.findRole(...) by id.
  • allUsers expands nested groups; users returns direct members only; managers gives the team managers (BAW 8.6+ teams).
  • Large LDAP groups: consider TWRole.allUsers once per team and cache in a shared object or an environment variable; the call is expensive.
  • Over REST the same is GET /rest/bpm/wle/v1/group/{groupName}?includeDeleted=false&parts=all (members array).

References

Related questions

0 votes
1 answer 1.6k views
asked Jun 16, 2016 by pavan (260 points)
0 votes
1 answer 2.0k views
0 votes
1 answer 847 views
0 votes
1 answer 2.1k views
0 votes
1 answer 1.3k views
+1 vote
1 answer 2.5k 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
...