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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Assign User to Role in CR for use in CN

jlittle
6-Contributor

Assign User to Role in CR for use in CN

I am trying to get the user that completes a specific task in the ECR, assign them to a Role and propogate that to the ECN. Here is what I have thus far:


wt.inf.container.WTContainer cont = ((wt.inf.container.WTContained)primaryBusinessObject).getContainer();
wt.inf.team.ContainerTeam contTeam = wt.inf.team.ContainerTeamHelper.service.getContainerTeam( (wt.inf.team.ContainerTeamManaged)cont);
wt.org.WTPrincipal wtprincipal1 = wt.session.SessionMgr.getPrincipal();
chgmgmtldr = (wt.org.WTUser)wt.session.SessionMgr.getPrincipal();
wt.inf.team.ContainerTeamHelper.service.addMember(contTeam,crLeader,wtprincipal1);



Printing the values for these looks correct:


Container= Test Product


contTeam= Product Test Product


wtprincipal1= User
name = Administrator
inflated = true......etc


However, what gets assigned to Role crLeader is a value of ASSIGNEE. Not what I wanted. I would expect it would be the wtprincipal as shown. How can I get this assigned correctly and am I going down the correct path to get this user/role from the ECR to the ECN?


Thanks,


James


4 REPLIES 4
jlittle
6-Contributor
(To:jlittle)



Wanted to follow-up and show the results for any future reference. I have a task assigned to a Role that has multiple users. I want to know who actually completes the task so I add this code to the Complete Transaction for that task:


chgmgmtldr = (wt.org.WTUser)wt.session.SessionMgr.getPrincipal();
wt.change2.WTChangeRequest2 request = ((wt.change2.WTChangeRequest2)primaryBusinessObject);
wt.team.Team team=(wt.team.Team)request.getTeamId().getObject();
java.util.Vector roles=team.getRoles();
for (int i=0;i<roles.size();i++) {<br="/> wt.project.Role role=(wt.project.Role)roles.get(i);
if (role.getStringValue().equalsIgnoreCase("wt.project.role.CHANGE MANAGER")) {
team.addPrincipal(role,chgmgmtldr);


}


This adds the user that completes the task to the "CHANGE MANAGER" Role for the Change Request.


I then need this user in the Change Notice. so I added this to a robot where several other attributes get populated:


String role2=new String("wt.project.role.CHANGE MANAGER");
com.ptc.windchill.pdmlink.change.server.impl.WorkflowProcessHelper.setRoleToECN((wt.change2.WTChangeOrder2)primaryBusinessObject,role2);



The problem this solves is I have tasks in the Change Notice that have to be assigned to a particular user that completes a task in the Change Request. Problem solved.



Regards,



I am trying to get the user that completes a specific task in the ECR, assign them to a Role and propogate that to the ECN. Here is what I have thus far:


wt.inf.container.WTContainer cont = ((wt.inf.container.WTContained)primaryBusinessObject).getContainer();
wt.inf.team.ContainerTeam contTeam = wt.inf.team.ContainerTeamHelper.service.getContainerTeam( (wt.inf.team.ContainerTeamManaged)cont);
wt.org.WTPrincipal wtprincipal1 = wt.session.SessionMgr.getPrincipal();
chgmgmtldr = (wt.org.WTUser)wt.session.SessionMgr.getPrincipal();
wt.inf.team.ContainerTeamHelper.service.addMember(contTeam,crLeader,wtprincipal1);



Printing the values for these looks correct:


Container= Test Product


contTeam= Product Test Product


wtprincipal1= User
name = Administrator
inflated = true......etc


However, what gets assigned to Role crLeader is a value of ASSIGNEE. Not what I wanted. I would expect it would be the wtprincipal as shown. How can I get this assigned correctly and am I going down the correct path to get this user/role from the ECR to the ECN?


Thanks,


James



This is great James! Thank you for posting the solution

[cid:image001.gif@01CDB814.EFBC8AA0]

Steve Vinyard
Application Engineer

Side note: What version of Windchill did your perform this on?

[cid:image001.gif@01CDB815.25915D40]

Steve Vinyard
Application Engineer
jlittle
6-Contributor
(To:jlittle)

We are currently on 9.1 M060 and are in the process of going to 10.0 M040.




In Reply to Steve Vinyard:


Side note: What version of Windchill did your perform this on?

[cid:image001.gif@01CDB815.25915D40]

Steve Vinyard
Application Engineer
Top Tags