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

Community email notifications are disrupted. While we are working to resolve, please check on your favorite boards regularly to keep up with your conversations and new topics.

Workflow assignee question

vmcdaniel
2-Guest

Workflow assignee question

Hello,

I have been able to find some pieces of what is needed to implement this change, some questions remain I hope you can help with.

We assign a task to a Context Role which has a Group as its members. This assigns a Work Item to each group member and completes with ANY vote. We would like to capture the participant who completed a task, and replace the current Role participants in the workflow with that individual.

Here's what I know:

1. To Capture the participant who completed the Work Item: Task_Complete_User = (wt.org.WTUser)wt.session.SessionMgr.getPrincipal();  from Here

Here's what I need help on still:

2. How to Remove existing Principal in the Role

3. How to Add Task_Complete_User in to Role

I think I found it here

1 ACCEPTED SOLUTION

Accepted Solutions

Here is the code I'm using in the Complete transition of the activity. WC10.2 M030

try{

//SET COMPLETED BY

wt.org.WTUser Task_Complete_User = (wt.org.WTUser)wt.session.SessionMgr.getPrincipal();

if (Task_Complete_User != null){  //task1User is a wt.org.WTUser variable

  //System.out.println("Enter Set Team");

  //SET TEAM

  wt.team.Team team = wt.team.TeamHelper.service.getTeam((wt.team.TeamManaged) primaryBusinessObject);

  //System.out.println("Team is  "+team);

  //System.out.println("Enter Roles");

  //SET THE ROLES

  wt.project.Role  teamRole = wt.project.Role.toRole("Sourcing");

  //System.out.println("Enter Remove Participant");

  //REMOVE THE CURRENT PARTICIPANT

  wt.org.WTPrincipal removeUser = null;

  wt.team.TeamHelper.service.deleteRolePrincipalMap( teamRole,removeUser,team);

  //System.out.println("Enter Set Participant");

  //ADD THE PARTICIPANTS TO THE TO_ROLES

  wt.team.TeamHelper.service.addRolePrincipalMap( teamRole, Task_Complete_User, team );

}

}

catch(Exception e){

  System.out.println("Error in workflow expression");

   e.printStackTrace();

  }

View solution in original post

2 REPLIES 2

Remote existing principals

  RoleHolder2 rholder = TeamHelper.service.getTeam(mTeam);

     Role rol = = Role.toRole("APPROVER");

        Enumeration enum = rh2.getPrincipalTarget(rol);

        while (enum.hasMoreElements()) {

            WTPrincipal user = ((WTPrincipalReference) e.nextElement()).getPrincipal();

            rholder.deletePrincipalTarget(rol, user);

                                   }

Add Task Completed User back

List<WorkItem> wItems = WfWorkflowStatusHelper.service.getWorkItems(assignAct);

        for (WorkItem witem : wItems) {

            if (witem.isComplete()) {

                WTUser user = OrganizationServicesMgr.getUser(witem.getCompletedBy());

                rh.addPrincipal(rol, user);

            }

        }

Thanks you

Binesh Kumar

Medtronic - MITG

Here is the code I'm using in the Complete transition of the activity. WC10.2 M030

try{

//SET COMPLETED BY

wt.org.WTUser Task_Complete_User = (wt.org.WTUser)wt.session.SessionMgr.getPrincipal();

if (Task_Complete_User != null){  //task1User is a wt.org.WTUser variable

  //System.out.println("Enter Set Team");

  //SET TEAM

  wt.team.Team team = wt.team.TeamHelper.service.getTeam((wt.team.TeamManaged) primaryBusinessObject);

  //System.out.println("Team is  "+team);

  //System.out.println("Enter Roles");

  //SET THE ROLES

  wt.project.Role  teamRole = wt.project.Role.toRole("Sourcing");

  //System.out.println("Enter Remove Participant");

  //REMOVE THE CURRENT PARTICIPANT

  wt.org.WTPrincipal removeUser = null;

  wt.team.TeamHelper.service.deleteRolePrincipalMap( teamRole,removeUser,team);

  //System.out.println("Enter Set Participant");

  //ADD THE PARTICIPANTS TO THE TO_ROLES

  wt.team.TeamHelper.service.addRolePrincipalMap( teamRole, Task_Complete_User, team );

}

}

catch(Exception e){

  System.out.println("Error in workflow expression");

   e.printStackTrace();

  }

Top Tags