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

We are happy to announce the new Windchill Customization board! Learn more.

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

ljeyachandran
7-Bedrock

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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)

        

      }

View solution in original post

2 REPLIES 2

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)

        

      }

helped a lot ,thank u very much
Top Tags