Add Team From startup event in liferay 6.2 ga4

75 Views Asked by At

i'm currently developing hook for user registration (jsp , action ,startup action) i wont at startup time (application.startup.events) to create 2 teams using this code but isn't work

Team team=TeamLocalServiceUtil.createTeam(CounterLocalServiceUtil.increment());
    team.setCompanyId(companyId);
    team.setName("individual");
    team.setDescription("individual individual");
    TeamLocalServiceUtil.addTeam(team);

could any one help me


and I've inspected team table in database there are 2 fields (companyid and groupid ) i can't see what is difference between them they are facing me any where what their benefit and how i can find them

2

There are 2 best solutions below

0
On BEST ANSWER

companyId is what the UI calls "instance". Most likely you have only one. The technical name groupId typically refers to the site that you create the team in.

I'd rather advise to create the team in a single call:

Team team = TeamLocalServiceUtil.addTeam(ownerId, groupId, name, description)

If this doesn't help, please update your question with more information than "doesn't work". You can be a lot more specific.

0
On

companyId is the liferay portal instance id. If you setup liferay to be multi-tenant, this id is used to separate data between the virtual portal.

groupId is organizational or site id.It's used if you want to separate your data between organization or sites.

try below code to add team :-

Team team=teamPersistence.create(CounterLocalServiceUtil.increment(Team.class.toString()));
team.setCompanyId(companyId);
team.setName("individual");
team.setDescription("individual individual");

teamPersistence.update(team);