Programmatically assign a task participant
Hello, all!
For a current workflow task, how do I programmatically add a user and assign them the current task (add them to the current task pool)?
So. Adding users to a role via api. Check. There are a bunch of ways to do this, actually. The two main ways were getting the team for the object and adding and getting the process team (which I figure is the same in this case?) and adding the participant.
I can add the participant, but the task for that role is not generating. As always, I figure I am missing something obvious.......
Latest iteration I was trying:
private String assignUserToRole(WTChangeOrder2 coIn,String roleNameIn,String userNameToAdd){
Vector<Role> rolesToReturn = new Vector<Role>();
StringBuilder dataToReturn = new StringBuilder();
try{
Team curCNTeam = TeamHelper.service.getTeam(coIn);
rolesToReturn = curCNTeam.getRoles();
for(Role curRole:rolesToReturn){
if(curRole.getDisplay().toLowerCase().contains(roleNameIn.toLowerCase())){
QuerySpec qs = new QuerySpec(wt.org.WTUser.class);
qs.appendWhere(new SearchCondition(wt.org.WTUser.class, wt.org.WTUser.NAME, SearchCondition.LIKE, userNameToAdd,false), null);
StatementSpec statementSpec = (StatementSpec) qs;
QueryResult qr = PersistenceHelper.manager.find(statementSpec);
if (qr.size() > 0) {
wt.org.WTUser user = (wt.org.WTUser) qr.nextElement();
TeamHelper.service.addRolePrincipalMap(curRole, user, curCNTeam);
}
}
}
}
}
catch(WTException e){
e.printStackTrace();
dataToReturn.append("Error adding " + userNameToAdd + " to role " + roleNameIn);
}
return dataToReturn.toString();
}
