Add a user to a workflow's PBO's team
I have a workflow that I'd like to have the user select a user, then have the workflow update the PBO's team and add it to a specific role.
- I created the WTUser variable in the workflow,
- I created a method to take the user and put it into the PBO's team. There is some debugging statements in here and it outputs the team before and the team after.
The expression runs successfully but the before and after team look identical with the user not showing in the output, but if you go to the UI it shows the users.
Any ideas what I'm doing wrong?
public static void addUserToRole(ObjectReference self, String toRole, WTUser currentUser) throws WTException{
Role to_role = Role.toRole(toRole);
wt.team.WTRoleHolder2 team = null;
try {
team = TeamHelper.service.getTeam( (TeamManaged)self.getObject());
System.out.println("_____________BEFORE___________________");
System.out.println("ROLE: " + to_role.toString());
System.out.println("USER: " + currentUser.getFullName());
System.out.println("TEAM: " +team.getDisplayIdentity());
debugTeam(team, currentUser);
TeamHelper.service.addRolePrincipalMap(to_role, (WTPrincipal)currentUser, team );
} catch (TeamException e1) {
e1.printStackTrace();
} catch (WTRuntimeException e1) {
e1.printStackTrace();
} catch (WTException e1) {
e1.printStackTrace();
}
System.out.println("_____________AFTER___________________");
team = TeamHelper.service.getTeam( (TeamManaged)self.getObject());
debugTeam(team, currentUser);
}
private static void debugTeam(WTRoleHolder2 team, WTUser currentUser) throws WTException {
//wt.team.WTRoleHolder2 team = wt.team.TeamHelper.service.getTeam((wt.team.TeamManaged) primaryBusinessObject);
java.util.Vector roles = team.getRoles();
System.out.println("_____________________________________");
System.out.println("ADDING: " + currentUser.getFullName());
for( java.util.Enumeration e = roles.elements(); e.hasMoreElements(); ){
wt.project.Role role = (wt.project.Role) e.nextElement();
java.util.Enumeration participants = team.getPrincipalTarget( role );
System.out.println("ROLE: " + role.toString());
while( participants.hasMoreElements() ){
wt.org.WTPrincipalReference participant = (wt.org.WTPrincipalReference) participants.nextElement();
System.out.println("---Role: " + role.toString() + " Participant: " + participant.getFullName());
}
}
System.out.println("_____________________________________");
}

