Gaurav Sharma
Gaurav Sharma

Reputation: 4052

Liferay: Getting the Organization Id for a top-level organization

I'm able to get the organizationId of regular organizations using the following code:

ThemeDisplay themeDisplay = LiferayFacesContext.getInstance().getThemeDisplay();
long liferayOrganizationId = themeDisplay.getScopeGroup().getOrganizationId();

But this code does not work for top-level orgs. How would I get the organizationId for a top-level organization?

Upvotes: 1

Views: 1981

Answers (1)

Olaf Kock
Olaf Kock

Reputation: 48067

This works for top-level organizations as well. However, when you're using this in a site that is not associated to any organization, it will naturally not reveal a valid organization id.

Note that Liferay 6.1 now has sites, which contain all the pages. Organizations can have sites, but don't need to. Sites can well exist without any organization being associated with them. And that's when you get 0 as the organizationId result from the code in your question

Upvotes: 3

Related Questions