Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
Yannick Weinz
Organisation Ids of user are wrong
January 25, 2012 2:12 AM
Answer

Yannick Weinz

Rank: Junior Member

Posts: 69

Join Date: November 15, 2010

Recent Posts

Hi,

i got a litle problem with the Organisations of a user.
I can get the ids just fine using user.getOrganizationIds(). But the problem now is, that those ids are wrong.
For example, a User is in an Organization with the "Group ID" (still wonder why it isn't called "Organization ID") 29911. But when i now get the Organization IDs of that user via user.getOrganizationIds(), i get the ID 29910, altho there is no Organization with the ID 29910, just one with 29911, so i think that the getOrganizationIds() function somehow returns the wrong ID (i.e. giving an ID lowered by 1).

Any help how to deal with this Problem? (so far i simply incremented the id by 1 if i know looked for the organization, but that can't be the right way....)

Sincerely,

Yannick
Hitoshi Ozawa
RE: Organisation Ids of user are wrong
January 26, 2012 4:57 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

Which version of Liferay are you using?

Are you doing something similar to the following thread?
http://www.liferay.com/community/forums/-/message_boards/message/1536285
Daniel Romero
RE: Organisation Ids of user are wrong
April 23, 2012 3:33 PM
Answer

Daniel Romero

Rank: New Member

Posts: 3

Join Date: April 23, 2012

Recent Posts

Hi,

I'm having a similar problem, when I try to get the organization ID using this code
1themeDisplay.getLayout().getGroupId()
the returned ID is increased by 1.

I'm using LIferay CE 6.0.6

Thanks in advance

Daniel
David H Nebinger
RE: Organisation Ids of user are wrong
April 23, 2012 4:56 PM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7157

Join Date: September 1, 2006

Recent Posts

Increased by 1 as compared to what?

I hope you realize that themeDisplay.getLayout() is returning the layout information which may or may not be connected with the user.

That and layout.getGroupId() is returning a group id, and is not necessarily an organization id...
Daniel Romero
RE: Organisation Ids of user are wrong
April 23, 2012 5:15 PM
Answer

Daniel Romero

Rank: New Member

Posts: 3

Join Date: April 23, 2012

Recent Posts

David H Nebinger:
Increased by 1 as compared to what?

I hope you realize that themeDisplay.getLayout() is returning the layout information which may or may not be connected with the user.

That and layout.getGroupId() is returning a group id, and is not necessarily an organization id...


It is returning the organizationId increased by 1 compared with the database organizationId value. I tested it in other server (with Liferay CE 6.0.6) and it works.
David H Nebinger
RE: Organisation Ids of user are wrong
April 23, 2012 5:59 PM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7157

Join Date: September 1, 2006

Recent Posts

The group id and the organization id are two different things.

If you look in the groups_ tables in both databases, I'm sure you'll find in the one database that it works the group id happens to be the same as the numerical value stored in the name column (and the classPK column). In the database where it's wrong, the group id will not match the numerical value in the name column (and the classPK column).

That is indicating that you're using the group id incorrectly. It never is or was guaranteed to be the same as the organization id. Just because you found it to be the case once doesn't mean you can therefore infer that it will be the same every time.
Daniel Romero
RE: Organisation Ids of user are wrong
April 23, 2012 7:34 PM
Answer

Daniel Romero

Rank: New Member

Posts: 3

Join Date: April 23, 2012

Recent Posts

David H Nebinger:
The group id and the organization id are two different things.

If you look in the groups_ tables in both databases, I'm sure you'll find in the one database that it works the group id happens to be the same as the numerical value stored in the name column (and the classPK column). In the database where it's wrong, the group id will not match the numerical value in the name column (and the classPK column).

That is indicating that you're using the group id incorrectly. It never is or was guaranteed to be the same as the organization id. Just because you found it to be the case once doesn't mean you can therefore infer that it will be the same every time.


Thanks for your quick response!

I already found a way to get the current organizationId:

1themeDisplay.getLayout().getGroup().getOrganizationId()
Hitoshi Ozawa
RE: Organisation Ids of user are wrong
April 23, 2012 7:26 PM
Answer

Hitoshi Ozawa

Rank: New Member

Posts: 3

Join Date: April 1, 2010

Recent Posts

I'm looking at Liferay 6.1.0 GA1 table and it seems alright. FYI, Liferay.com doesn't fix past versions.