cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Set Up Participants Tab

SOLVED
Highlighted
Moonstone

Set Up Participants Tab

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Set Up Participants Tab

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());
}
}
}

View solution in original post

6 REPLIES 6
Highlighted

Re: Set Up Participants Tab

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());
}
}
}

View solution in original post

Highlighted

Re: Set Up Participants Tab

Brain,

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

Highlighted

Re: Set Up Participants Tab

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.

Highlighted

Re: Set Up Participants Tab

Brian, This is the error that I received when checking your code...any ideas?

Checking Syntax...

D:\PTC\Windchill_10.2\Windchill\temp\WfExpression99652757.java:105: error: '(' expected

if x=1 {

^

D:\PTC\Windchill_10.2\Windchill\temp\WfExpression99652757.java:105: error: ')' expected

if x=1 {

^

2 errors

Syntax check complete.

Highlighted

Re: Set Up Participants Tab

Greg,

Can you send me the complete code? Either something got deleted in what I copied, or if you copied or typed in something is missing possibly.

Highlighted

Re: Set Up Participants Tab

Hello Brian,

How can i remove required role from activity.

Announcements