I accidentally marked this as the solution when it wasn't. It was that the internet was too slow and I double hit the reply but it decided it liked the solution button. 🤣 When I did my testing initially, I made statement one false, so when I get into testing multiple scenarios, I found that it didn't work. Below though is code that works now.
You actually have to use multiple variables for the Iterator and use a different one at each IF. This was the easiest and one that worked the quickest from Tech Support.
wt.workflow.work.WfAssignedActivity act = (wt.workflow.work.WfAssignedActivity) self.getObject();
wt.workflow.engine.WfProcess pro = (wt.workflow.engine.WfProcess) act.getParentProcess();
wt.team.Team t = wt.team.TeamHelper.service.getTeam(pro);
java.util.Map members = t.getRolePrincipalMap();
java.util.Set keys = members.keySet();
java.util.Iterator itr = keys.iterator();
java.util.Iterator itr1 = keys.iterator();
java.util.Iterator itr2 = keys.iterator();
java.util.Iterator itr3 = keys.iterator();
if(<attribute1>.equalsIgnoreCase("<value1>")){
while (itr.hasNext()) {
wt.project.Role role = (wt.project.Role) itr.next();
if (role.toString().equalsIgnoreCase("<role1>")) {
java.util.ArrayList users = (java.util.ArrayList) members.get(role);
//If there is no user in role1 role throw exception
if (users.isEmpty()) {
throw new Exception("Select user for " + role.getDisplay());
}
}
}
}
if(<attribute2>.equalsIgnoreCase("<value2>")){
while (itr1.hasNext()) {
wt.project.Role role = (wt.project.Role) itr1.next();
if (role.toString().equalsIgnoreCase("role1")) {
java.util.ArrayList users = (java.util.ArrayList) members.get(role);
//If there is no user in role1 role throw exception
if (users.isEmpty()) {
throw new Exception("Select user for " + role.getDisplay());
}
}
}
}
if (<attribute3>.equalsIgnoreCase("<value3>")){
while (itr2.hasNext()) {
wt.project.Role role = (wt.project.Role) itr2.next();
if (role.toString().equalsIgnoreCase("role1")) {
java.util.ArrayList users = (java.util.ArrayList) members.get(role);
//If there is no user in role1 role throw exception
if (users.isEmpty()) {
throw new Exception("Select user for " + role.getDisplay());
}
}
}
}
if (<attribute3>.equalsIgnoreCase("<value4>")){
while (itr3.hasNext()) {
wt.project.Role role = (wt.project.Role) itr3.next();
if (role.toString().equalsIgnoreCase("role2")) {
java.util.ArrayList users = (java.util.ArrayList) members.get(role);
//If there is no user in role2 role throw exception
if (users.isEmpty()) {
throw new Exception("Select user for " + role.getDisplay());
}
}
}
}