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

How to store Team object by code?

SOLVED
AntonBagryanov
Visitor

How to store Team object by code?

Hi to all!

I am storing the Team object like:

PersistenceHelper.manager.store(myTeam);

Then I can query this team by name, but RolePrincipalmap is empty.

Anybody know how to store team object correct? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to store Team object by code?

Hi guys!

Thanks for your answers.

I have solved this problem. If you need to store the Team object with non empty RolePrincipalMap you should:

1) Store the Team object like follow (pn is the PromotionNotice object):

Team newTeam = Team.newTeam();

  newTeam.setName(pn.getNumber() + "pnTeam");

  newTeam.setDomainRef(pn.getDomainRef());

  newTeam = (Team)PersistenceHelper.manager.save(newTeam);

2) Create and store RolePrincipalMap objects for all roles and users you need like follow:

RolePrincipalMap rpm = RolePrincipalMap.newRolePrincipalMap();

  rpm.setWTRoleHolder2(newTeam);

  rpm.setRole(role);

  rpm.setPrincipalParticipant(wtpr);

  PersistenceHelper.manager.save(rpm);

Then you can query your Team object and getRolePrincipalMap will return you current RolePrincipalmap

View solution in original post

4 REPLIES 4

Re: How to store Team object by code?

You can use the API wt.team.TeamHelper.service

Thank you

Binesh Kumar

Re: How to store Team object by code?

Anton,

Have you tried below API:

TeamTemplate teamTemplate = TeamTemplate.newTeamTemplate();

teamTemplate.setTeamTemplateIdentity(templateName);

teamTemplate.setContainer(container);

FolderHelper.assignLocation((FolderEntry)teamTemplate, folder);

teamTemplate.setEnabled(true);

teamTemplate = (TeamTemplate)PersistenceHelper.manager.store(teamTemplate);

return teamTemplate;

Regards,

Shirish

Re: How to store Team object by code?

Anton,

Do you want to store the Team Template, team instance or context team ?

can you  explain your requirement to store/create new team?

Thanks

Shreyas

Re: How to store Team object by code?

Hi guys!

Thanks for your answers.

I have solved this problem. If you need to store the Team object with non empty RolePrincipalMap you should:

1) Store the Team object like follow (pn is the PromotionNotice object):

Team newTeam = Team.newTeam();

  newTeam.setName(pn.getNumber() + "pnTeam");

  newTeam.setDomainRef(pn.getDomainRef());

  newTeam = (Team)PersistenceHelper.manager.save(newTeam);

2) Create and store RolePrincipalMap objects for all roles and users you need like follow:

RolePrincipalMap rpm = RolePrincipalMap.newRolePrincipalMap();

  rpm.setWTRoleHolder2(newTeam);

  rpm.setRole(role);

  rpm.setPrincipalParticipant(wtpr);

  PersistenceHelper.manager.save(rpm);

Then you can query your Team object and getRolePrincipalMap will return you current RolePrincipalmap

View solution in original post

Polls

Windchill Customers

What browser do you most commonly use? (Chrome, Firefox, Edge Chromium, Internet Explorer 11, Safari, Other)

Announcements
Learn more about how we are using our browser poll here