liferay unasign user to delete organizations

522 views Asked by At

I'm new to Liferay and work on a site done with Liferay 6.1.1.

I have a question about deleting organization. When I try to delete an organization, I have an error message

You cannot delete organizations that have suborganizations or users.

I found that before deleting the organization, I had to delete this organization's site and unasign all user manually, then the organization can be delete without error.

Does anybody know if it is possible to add a property or edit the delete function so when you try to delete an organization it'll do the previous task automatically ?

1

There are 1 answers

0
Laxman Rana On

I think it is not possible to achieve/fulfill your requirement just by setting property. However, you can achieve this by creating Hook in liferay. Inside hook you can use below Liferay's api :

  • For deleting sub organization you can use OrganizationLocalServiceUtil.getSuborganizations(long companyId, long organizationId) which will return list of sub organization. You can iterate this list and call OrganizationLocalServiceUtil.deleteOrganization(long organizationId) which will delete sub organization.
  • To Unassigned users from org, use UserLocalServiceUtil.clearOrganizationUsers(long organizationId)

HTH