Need to know how to get the users of multiple role from a Library context and add them as a project manager in the project context
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Need to know how to get the users of multiple role from a Library context and add them as a project manager in the project context
Im using windchill 10.1 M030, We have written a code for creating project automatically based on the lifecycle state of the document. When the document is released, the project will be created by the listener. Now the users are added manually in the respective roles in the project. Instead i wanted to add a particular members of a role from library as a project manager in the project context. Need help with this.
Solved! Go to Solution.
- Labels:
-
Other
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi all,
I have found the solution. below is the code snippet for achieving this
ContainerTeam libteam = ContainerTeamHelper.service.getContainerTeam((ContainerTeamManaged) pif.getContainer()); (pif is the WTDoc object)
HashMap map = libteam.getAllMembers();
Set keys = map.keySet();
Iterator itr = keys.iterator();
WTPrincipalReference UserName;
Object Role1;
Role ppeRole=null;
while(itr.hasNext())
{
UserName = (WTPrincipalReference)itr.next();
Role1 = map.get(UserName);
if(Role1.toString().contains("PDE PLANNING ENGINEER")) (custom role where the users are retrieved)
{
System.out.println(UserName.getName() + "-----------------" +Role1);
ContainerTeamHelper.service.addMember(localContainerTeam, ppeRole.toRole("PROJECT MANAGER"),UserName.getPrincipal() ); (retreived users are added in the role of Project Manager)
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi all,
I have found the solution. below is the code snippet for achieving this
ContainerTeam libteam = ContainerTeamHelper.service.getContainerTeam((ContainerTeamManaged) pif.getContainer()); (pif is the WTDoc object)
HashMap map = libteam.getAllMembers();
Set keys = map.keySet();
Iterator itr = keys.iterator();
WTPrincipalReference UserName;
Object Role1;
Role ppeRole=null;
while(itr.hasNext())
{
UserName = (WTPrincipalReference)itr.next();
Role1 = map.get(UserName);
if(Role1.toString().contains("PDE PLANNING ENGINEER")) (custom role where the users are retrieved)
{
System.out.println(UserName.getName() + "-----------------" +Role1);
ContainerTeamHelper.service.addMember(localContainerTeam, ppeRole.toRole("PROJECT MANAGER"),UserName.getPrincipal() ); (retreived users are added in the role of Project Manager)
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator