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