Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Leonardo Santos-Macias
Create an organization
June 8, 2011 9:45 AM
Answer

Leonardo Santos-Macias

Rank: New Member

Posts: 2

Join Date: May 18, 2011

Recent Posts

I need some help creating a new organization

Everything I have found and tried takes an orgId, I am looking for something like new Organization() that or .create() that creates one with the next available id.

I tried OrganizationUtil.create(0) and OrganizationUtil.create(-1) and a new Org was created with either id 0 or even -1
Julien Bonjean
RE: Create an organization
June 8, 2011 9:49 AM
Answer

Julien Bonjean

Rank: Junior Member

Posts: 57

Join Date: June 10, 2009

Recent Posts

You should use OrganizationLocalServiceUtil.addOrganization method.
Leonardo Santos-Macias
RE: Create an organization
June 8, 2011 10:06 AM
Answer

Leonardo Santos-Macias

Rank: New Member

Posts: 2

Join Date: May 18, 2011

Recent Posts

thanks... but I already tried that and takes either user or organization object. The first one is ok but I need this for a "company admin" portlet, do not want to add the current user to the organization, just create one with no users. The second one takes an existing org and I can't do Organization = new Organization()

OrganizationLocalServiceUtil.addOrganization(userId, parentOrganizationId, name, type, recursable, regionId, countryId, statusId, comments, serviceContext)
OrganizationLocalServiceUtil.addOrganization(organization)
Julien Bonjean
RE: Create an organization
June 8, 2011 10:06 AM
Answer

Julien Bonjean

Rank: Junior Member

Posts: 57

Join Date: June 10, 2009

Recent Posts

You can try with default user:
long defaultUserId = UserLocalServiceUtil.getDefaultUserId(companyId);