Skip to main content
16-Pearl
January 29, 2015
Solved

Set Up Participants Tab

  • January 29, 2015
  • 6 replies
  • 2908 views

Is there a way to FORCE a participant to be selected before a user completes task? Some sort of check that will not allow task competition unit a participant is selected?

Best answer by BrianToussaint

Yes, you will need to put code in under the Transitions tab for the transition that will send it on.

Here is sample code. You will need to change it for your specific role in the workflow. It will put up a box telling the user that there is no one in the role.

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();
while (itr.hasNext()) {
wt.project.Role role = (wt.project.Role) itr.next();
System.out.println("Role-=-=-=" + role);
if (role.toString().equalsIgnoreCase("specify_role_here")) {
java.util.ArrayList users = (java.util.ArrayList) members.get(role);
//If there is no user in specify_role_here role throw exception
if (users.isEmpty()) {
throw new Exception("Select user for " + role.getDisplay());
}
}
}

6 replies

19-Tanzanite
January 29, 2015

Yes, you will need to put code in under the Transitions tab for the transition that will send it on.

Here is sample code. You will need to change it for your specific role in the workflow. It will put up a box telling the user that there is no one in the role.

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();
while (itr.hasNext()) {
wt.project.Role role = (wt.project.Role) itr.next();
System.out.println("Role-=-=-=" + role);
if (role.toString().equalsIgnoreCase("specify_role_here")) {
java.util.ArrayList users = (java.util.ArrayList) members.get(role);
//If there is no user in specify_role_here role throw exception
if (users.isEmpty()) {
throw new Exception("Select user for " + role.getDisplay());
}
}
}

GregOlson16-PearlAuthor
16-Pearl
March 12, 2015

Brain,

What would the code look like if you have two roles that need to be filled in (engineer and sales manager)?

19-Tanzanite
March 13, 2015

Greg,

I have to admit that I got this basic code from someone else and am not the world's best programmer. I've never had the need for two roles to be filled out. From the programming side, I would see if a "for loop" with "if statements". Maybe something like this (I definitely do not guarantee this). If both are empty, it might make you fill out the one and do the other. I think I have enough { }'s in there, but you might want to check.

while (itr.hasNext()) {

wt.project.Role role = (wt.project.Role) itr.next();

System.out.println("Role-=-=-=" + role);

for (int x=1; x <2; x++){

if x=1 {

if (role.toString().equalsIgnoreCase("specify_role_here")) {

java.util.ArrayList users = (java.util.ArrayList) members.get(role);

//If there is no user in specify_role_here role throw exception

if (users.isEmpty()) {

throw new Exception("Select user for " + role.getDisplay());

}

}

else {

if (role.toString().equalsIgnoreCase("specify_role2_here")) {

java.util.ArrayList users = (java.util.ArrayList) members.get(role);

//If there is no user in specify_role2_here role throw exception

if (users.isEmpty()) {

throw new Exception("Select user for " + role.getDisplay());

}

}

}

}

}

}

On the non-programming side. Does the person at this stage fill out both roles? Are these tasks simultaneous or are they sequential? If they are sequential, can you put a check in at one level for the other, like at the engineer check to see if sales manager is in there?

If you try the code above, please let me know if it works. I am interested to see. Also, I am sorry it took a while to answer, I have been catching up from a 10.1 to 10.2 upgrade last weekend.