Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Sergio Sanchez
Create an organization using the API
June 8, 2011 8:27 AM
Answer

Sergio Sanchez

Rank: Junior Member

Posts: 41

Join Date: February 3, 2011

Recent Posts

Hello liferayers,

I'm trying to create an organization using the API and I've written this groovy test to see if that's possible. After I run it I cannot see the new organization under the organizations list. Do I have to do anything else?

Thanks

1
2def org = com.liferay.portal.service.OrganizationLocalServiceUtil.createOrganization(com.liferay.portal.kernel.util.GetterUtil.getLong("11212"))
3org.setName("aaaa")
4com.liferay.portal.service.OrganizationLocalServiceUtil.addOrganization(org)
Tomas Polesovsky
RE: Create an organization using the API
June 8, 2011 1:33 PM
Answer

Tomas Polesovsky

LIFERAY STAFF

Rank: Liferay Master

Posts: 564

Join Date: February 13, 2009

Recent Posts

Hello Sergio,

try to create organization using OrganizationLocalServiceUtil:
1
2    public Organization addOrganization(
3            long userId, long parentOrganizationId, String name, String type,
4            boolean recursable, long regionId, long countryId, int statusId,
5            String comments, boolean site, ServiceContext serviceContext)
6        throws PortalException, SystemException;


or better - version with permission checking - OrganizationServiceUtil.addOrganization(...).

-- tom
Sergio Sanchez
RE: Create an organization using the API
June 9, 2011 3:17 AM
Answer

Sergio Sanchez

Rank: Junior Member

Posts: 41

Join Date: February 3, 2011

Recent Posts

Yes! it works. Thanks a lot
kevin chen
RE: Create an organization using the API
August 21, 2013 1:28 AM
Answer

kevin chen

Rank: New Member

Posts: 1

Join Date: August 21, 2013

Recent Posts

hi Tomáš Polešovský,
Can you tell me how to Create an organization whith the method OrganizationLocalServiceUtil.addOrganization(Organization) in liferay 6.1.1 version?
Thank you very much!
Ketan Savaliya
RE: Create an organization using the API
August 21, 2013 5:47 AM
Answer

Ketan Savaliya

Rank: Junior Member

Posts: 71

Join Date: March 3, 2011

Recent Posts

Hi Kevin,

As per your requirement, make a sample organization object and set all properties value properly like userId, parentOrganizationId, name, type etc. what ever required. then pass this object to OrganizationLocalServiceUtil.addOrganization(Organization)


Hope this will help you.

Thank you,
Ketan Savaliya